棰樺璇濓細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 鐜的主要内容,如果未能解决你的问题,请参考以下文章

绉掓潃绯荤粺鎬庝箞鎼烇紵铏愭浜?.....

姘稿埄缃戠珯娉ㄥ崟瀹℃牳澶辫触涓嶇粰鍑烘鎬庝箞鍔烇紵

鎬庝箞瀹炵幇鍗曞嚮span鏃剁粰span娣诲姞杈规

绀炬亹鎬庝箞鍔烇紵杩欎釜婕敾鎴栬鑳芥不鎰堜綘

鎬庝箞鐞嗚В鈥滈潪瀵圭О鍔犲瘑鈥濓紵

缁囨ⅵ鏈湴璋冭瘯濂界殑缃戠珯鎬庝箞涓婁紶鍒版湇鍔″櫒