棰樺璇濓細2020 骞磋鎬庝箞鐢?Intellij IDEA 鎼缓 Haskell 鐜
Posted Kotlin 缁翠慨杞﹂棿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了棰樺璇濓細2020 骞磋鎬庝箞鐢?Intellij IDEA 鎼缓 Haskell 鐜相关的知识,希望对你有一定的参考价值。
鐢变簬瀵瑰嚱鏁板紡缂栫▼浜嗚В鐨勮秺澶氾紝鎴戞渶杩戝氨瓒婃劅瑙?Kotlin 鐨勮娉曡繕涓嶅鈥滄縺杩涒€濓紝浜庢槸鎴戦鎯冲皾璇曚竴涓嬬湡姝g殑绾嚱鏁板紡璇█锛岃鍒扮函鍑芥暟寮忚瑷€锛屾渶鏈夊悕鐨勫簲璇ュ氨鏄?Haskell 浜嗐€侹otlin 涓轰紶缁熺殑 Java 寮€鍙戣€呭紑鍚簡鍑芥暟寮忕殑澶ч棬锛屼絾濡傛灉浣犳兂浜嗚В鐨勬洿澶氾紝瀛﹀ Haskell 鏄釜闈炲父妫掔殑閫夋嫨銆?/p>
鐢变簬鏄竴闂ㄢ€滃闄㈡淳鈥濈殑灏忎紬璇█锛孒askell 涓嶄粎澶熼叿锛岃€屼笖浣跨敤浜烘暟涔熻冻澶熷皯馃槶锛屾墍浠ュ湪缃戜笂铏界劧鑳芥壘鍒板皯閲忕殑鎼缓鐜鐨勬暀绋嬶紝浣嗘槸寰堝彲鑳界敱浜庢病鏈夋洿鏂拌€屽鑷撮噷闈㈢殑鏂规硶鐩墠宸茬粡鏃犳硶姝e父浣跨敤銆傛湰鏂囪褰曚竴涓嬫垜鐨勮俯鍧戣褰曪紝骞舵€荤粨浜嗕竴濂楀湪 Kotlin/Java 寮€鍙戣€呮渶鐔熸倝鐨勭幆澧冣€斺€擨ntellij IDEA 涓嬬敤鏈€绠€鍗曠殑鏂规硶鎼缓 Haskell 鐜鐨勮褰曘€?br>
娉ㄦ剰锛屾湰鏂囧熀浜?macOS銆?/p>
瀹夎 Haskell Stack
Haskell Stack 鏄竴涓潪甯告湁鐢ㄧ殑鍛戒护琛屽伐鍏凤紝瀹冨彲浠ヨ浣犵殑宸ュ叿瀹夎銆佺紪璇戙€佹瀯寤虹瓑宸ヤ綔涓€鏉¢緳瀹屾垚銆傛垜浠彲浠ヤ娇鐢ㄥ畼鏂规帹鑽愮殑鏂瑰紡瀹夎锛屾棦浣跨敤浠ヤ笅鍛戒护锛?/span>
curl -sSL https://get.haskellstack.org/ | sh
杩欑鏂瑰紡鍙互瀹夎鏈€鏂扮殑 Haskell Stack锛屼絾鏄敱浜庡浗鍐呯綉缁滅幆澧冪殑闂锛岃繖绉嶆柟寮忔湁鏃舵棤娉曟垚鍔燂紝閭d箞鎴戜滑涔熷彲浠ョ敤 Homebrew 鏉ュ畨瑁咃細
brew install haskell-stack
瀹夎瀹屾瘯涔嬪悗鍙互鐢ㄤ互涓嬪懡浠ら獙璇佸畨瑁呮槸鍚︽垚鍔燂細
stack --version
铏界劧瀹夎鎴愬姛浜嗭紝浣嗘槸 Homebrew 缁忓父鏃犳硶瀹夎 Haskell Stack 鐨?/span>鏈€鏂扮増鏈紝渚嬪锛屾垜瀹夎鐨勬椂鍊欙紝鏈€鏂扮増鏈槸 2.3.1锛岃€?Homebrew 瀹夎鐨勫垯鏄?2.1.3 鐗堟湰銆?/span>鎵€浠ュ湪瀹夎瀹屾垚浠ュ悗鎵ц鍛戒护锛?/span>
stack upgrade
杩欐牱灏卞彲浠ュ崌绾ц嚦 Haskell Stack 鐨勬渶鏂扮増鏈€?/p>
浣跨敤 Haskell Stack 瀹夎鍏朵粬宸ュ叿
Haskell Stack 瀹夎瀹屾垚浠ュ悗锛屾垜浠渶瑕佷娇鐢ㄥ畠鏉ュ畨瑁呬竴浜涙垜浠繀椤荤殑宸ュ叿锛岄鍏堟墽琛屽懡浠わ細
stack setup
杩欎細浣?Haskell Stack 鍒濆鍖栵紝骞朵负鎴戜滑鑷姩瀹夎 GHC锛圚askell 鐨勭紪璇戝櫒锛夈€?/p>
鐒跺悗鎴戜滑杩橀渶瑕佸畨瑁?cabal锛圚askell 鐨勫寘绠$悊宸ュ叿锛夛細
stack install cabal
瀹為檯涓婅繖鏍锋垜浠氨鍙互鍐欎唬鐮佷簡锛屼絾鏄敱浜庢垜浠兂鏈夋洿濂界殑浣撻獙锛屾垜涔熷缓璁畨瑁?hlint锛圚askell 鐨勪唬鐮佺缉杩涙鏌ワ級锛?br>
stack install hlint
缃戜笂鏈夌殑鏁欑▼杩樻帹鑽愬畨瑁?hindent 鍜?stylish-haskell锛岀敤 stack install 鍛戒护瀹夎锛岃€?stylish-haskell 铏界劧鍙互瀹夎锛屼絾鏄垜杩樻病鍙戠幇瀹冩槸骞插槢鐢ㄧ殑锛屾兂瑁呯殑涔熷彲浠ヨ涓€涓嬨€?/p>
閰嶇疆 Intellij IDEA
Intellij IDEA 鐩镐俊澶у鐢佃剳閲岄兘鏈夛紝濡傛灉鑳界敤涓€涓?IDE 鍋氭墍鏈夌殑浜嬶紝鎴戜篃鎳掑緱鍐嶅紕涓€涓畬鍏ㄤ笉鐔熸倝鐨勬柊鐜浜嗭紝鎵€浠ユ垜浠负 Intellij IDEA 瀹夎 Haskell 鎻掍欢銆?/span>
鐩存帴鍦ㄦ彃浠剁殑 Marketplace 涓悳绱⑩€渉askell鈥濓紝鎴戜滑鑳界湅鍒版悳绱㈢粨鏋滀腑鏈変袱涓彃浠讹紝涓€涓槸 Intellij-Haskell锛屽彟涓€涓槸 HaskForce銆備粠缁存姢鏃堕棿涓婃潵鐪?nbsp;Intellij-Haskell 鐨勭淮鎶ゆ椂闂存槸浠婂勾 4 鏈堬紝姣?nbsp;HaskForce 鐨勫幓骞?9 鏈堟洿杩戯紝鎵€浠ユ垜浠洿鎺ュ畨瑁?nbsp;Intellij-Haskell銆?/span>
鍒涘缓 Haskell 宸ョ▼
铏界劧鎴戜滑宸茬粡鏈変簡 Intellij-Haskell锛屼絾鏄繕鏄棤娉曚娇鐢?Intellij IDEA 鏉ユ櫤鑳界殑鍒涘缓 Haskell 宸ョ▼锛屾垜浠粛鐒堕渶瑕佷娇鐢?Haskell Stack 鍦ㄥ懡浠よ閲屽垱寤恒€?/span>
棣栧厛浠庡懡浠よ杩涘叆鍒颁綘鎯冲瓨鏀惧伐绋嬫枃浠剁殑鐩綍涓嬶紝鐒跺悗浣跨敤浠ヤ笅鍛戒护锛?br>
stack new <project name>
濡傛灉浣犱簡瑙e伐绋嬫ā鏉匡紝涔熷彲浠ュ湪宸ョ▼鐨勫悕瀛楀悗闈㈠姞涓婃ā鏉跨殑鍚嶅瓧锛屼緥濡?sample锛?br>
stack new hello-test sample
鍒涘缓瀹屾垚涔嬪悗浠庡懡浠よ杩涘叆鍒板伐绋嬬殑鐩綍锛岀劧鍚庤繕瑕佹墽琛屼袱涓楠わ紝棣栧厛锛屽垵濮嬪寲锛?br>
stack init
涔嬪悗鍐?build锛?br>
stack build
鐜板湪鏂板伐绋嬪凡缁忓噯澶囧ソ浜嗐€?/p>
Write the F**king Haskell
鐜板湪鐢?Intellij IDEA 鎵撳紑鎴戜滑鍒氭墠鐨勫伐绋嬶紝鍏蜂綋鏂规硶鏄€夋嫨鑿滃崟鐨勶細File -> New -> Project from Existing Sources锛岀劧鍚庡嬀閫夆€淚mport project from external model鈥濓紝鍐嶉€夋嫨 Haskell Stack锛屾渶鍚庡畠浼氳浣犻€夋嫨 SDK锛岃繖鏃跺€欐垜浠彲浠ュ湪鍒楄〃涓彂鐜版垜浠凡缁忓畨瑁呯殑 Haskell Stack锛屾渶鍚庣偣鍑?nbsp;Finish 灏卞畬鎴愪簡銆?br>
鐜板湪鍑嗗杩愯鈥淗ello Word鈥濓紝鎵惧埌宸ョ▼涓殑 Main.hs 鏂囦欢锛岀劧鍚庤緭鍏ヤ互涓嬩唬鐮侊細
main :: IO ()
main = print "Write the F**king Haskell"
鏈€鍚庡啀閰嶇疆涓€涓?Configuration锛屼篃灏辨槸鐐瑰嚮 Intellij IDEA 鑿滃崟涓嬫柟鐨勨€滈敜瀛愨€濆拰鈥滀笁瑙掑舰杩愯绗﹀彿鈥濅腑闂寸殑閭d釜閫夐」锛屽啀鐐瑰姞鍙凤紝閫夋嫨 Haskell Stack Runner锛屾渶鍚庡湪 name 鏍忎腑闅忎究杈撳叆涓€涓悕瀛楋紙涔熷彲浠ヤ笉杈擄級锛岀劧鍚庣偣鍑?OK 灏辫浜嗐€傜幇鍦ㄦ垜浠嵆浣垮悗缁涔犺繃绋嬩腑浠绘剰淇敼浠g爜锛屽彧瑕佺偣鍑烩€滀笁瑙掑舰杩愯鏍囧織鈥濆氨鑳介噸鏂扮紪璇戣繍琛屻€?/p>
韪╁潙璁板綍
1.涓嶈閰嶇疆鍥藉唴鐨勬簮銆傜綉涓婃湁浜涙暀绋嬩細鏁欐垜浠慨鏀?config.yaml 鏂囦欢鏉ラ厤缃竻鍗庢垨涓澶х殑婧愶紝杩欐牱鍙互鎻愰珮涓嬭浇閫熷害锛屼絾鏄湰浜轰翰娴嬶紝杩欎簺婧愮敱浜庢病鏈夋洿鏂帮紝鐩墠涓€鏃﹂厤缃紝鏃犺鎬庢牱锛屼笅杞介兘浼氬け璐ワ紝鎵€浠ヨ缁х画浣跨敤瀹樻柟婧愶紝濡傛灉瀚岄€熷害鎱紝鍙互灏濊瘯涓哄懡浠よ宸ュ叿閰嶇疆浠g悊銆?/span>
以上是关于棰樺璇濓細2020 骞磋鎬庝箞鐢?Intellij IDEA 鎼缓 Haskell 鐜的主要内容,如果未能解决你的问题,请参考以下文章