<Haskell> Emacs ã§ã®éçºç°å¢æ§ç¯ã¡ã¢
Emacs ã§ã® Haskell ã®éçºç°å¢æ§ç¯ã¡ã¢ï¼
以åæ¸ãã¦ãããã®ããã¡ãã¸ç§»ããã ããªã®ã§ï¼ç¾å¨ã¯å¤å°äºæ ãç°ãªã£ã¦ãããï¼ãããã Emacs ãããªã㦠VSCode ã¨ãã®æ¹ãããã£ããããããããã¾ããï¼
ç§ã®è¨å®ã¯ãã¡ãï¼
Intero for Emacs
Flycheck ãè£å®ã REPL çï¼æä½éå¿ è¦ãªæ©è½ãããä¸ã¤ã§ä¸éãæãã¾ãï¼Stack ã¨ã®ç¸æ§ãè¯ãï¼ä½¿ãåæãè¯ãã§ãï¼è©³ããã¯ å ¬å¼ ãåç §ï¼
Installing
å ¬å¼ ã«å¾ãã¾ãï¼
MELPA ãç»é²ãã¦ããªãå ´åã¯ï¼ããã±ã¼ã¸ã¢ã¼ã«ã¤ãã¹ã®ãªã¹ãã«è¿½å ããã¦ããã¾ãï¼
ä¾ãã°ï¼init.el
çã«æ¬¡ã®ããã«è¨è¿°ãã¾ãï¼
â» ç§ã®è¨å®ã¯ãããªæãï¼
(require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) (package-initialize) (package-refresh-contents)
init.el
ã¨ãã«ä»¥ä¸ãè¨è¿°ãã¦ãããï¼æãã¯æ®éã«ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããããã¾ãï¼
(package-install 'intero)
haskell-mode
ã« hook ãã¦ããã¾ãï¼
(add-hook 'haskell-mode-hook 'intero-mode)
Usage
ä¸ã®ããã«ãã¦ããã°ï¼.hs
ãã¡ã¤ã«çãéããæã«åæã« Intero ãèµ·åãã¦ããã¾ãï¼
ãã使ããã¤ï¼
intero-repl-load
ã§ï¼REPL ã§ç¾å¨éãã¦ãã module ã load ãã¦ãããï¼ããã©ã«ãã§ã¯C-c C-l
ã«å½ã¦ããã¦ãã¾ãï¼
ããã«å ãã¦ï¼å人çã« Flycheck 表示ç¨ã® window ãåæã«éãã³ãã³ããå®ç¾©ãã¦ãã¾ãï¼
(defun intero-repl-and-flycheck () (interactive) (delete-other-windows) (flycheck-list-errors) (intero-repl-load) (split-window-below) (other-window 1) (switch-to-buffer flycheck-error-list-buffer) (other-window 1) (windmove-right) )
ããã C-c C-p
ã«å½ã¦ã¦ããã¾ãï¼
(add-hook 'haskell-mode-hook '(lambda () (define-key intero-mode-map (kbd "C-c C-p") 'intero-repl-and-flycheck)))
HLint
HLint 㯠Haskell ç¨ã® lint ãã¼ã«ï¼ã½ã¼ã¹ã³ã¼ãæ¤æ»ãã¼ã«ï¼ã§ãï¼
ä¸è¦ãªè¨è¿°ãæ¨å¥¨ããã¦ããªãé¢æ°ãè¨èªæ¡å¼µãææãã¦ããããï¼ãã¢ã³ã¿ããæ¸ãã¦ããã©ï¼ãããªé¢æ°ããããã使ãã¨ããã§ï½ãã¿ãããªãã¨ãæãã¦ããã¾ãï¼
Installing
$ stack install hlint
ã§ãï½ï¼
Usage
åºæ¬çãªä½¿ãæ¹ã«é¢ãã¦ã¯ ãã¡ã ãã¨ã¦ãåèã«ãªãã¾ãï¼
Emacs ä¸ã§ã¯ flycheck ã§å©ç¨ããããï¼ã¾ãã¯ãããã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãï¼
ãã®ä¸ã§ï¼Intero ã¨å ±åãã形㧠HLint ã使ç¨ããããï¼æ¬¡ã®ããã«è¨è¿°ãã¾ãï¼
(flycheck-add-next-checker 'intero '(warning . haskell-hlint))
ãã¨ã¯åæã«è²ã æãã¦ãããã®ã§ï¼ã¨ã¦ã便å©ï¼
stylish-haskell
stylish-haskell ã¯ï¼ã½ã¼ã¹ã³ã¼ããèªåçã«ããæãã«æ´å½¢ãã¦ãããï¼import
ã case
æãæãã¦ãããï¼ãã¼ã«ã§ãï¼
Intalling
$ stack install stylish-haskell
Usage
save æã«åæã«æ´å½¢ãã¦ãããããï¼æ¬¡ã®ããã«è¨è¿°ãã¾ãï¼
(custom-set-variables '(haskell-stylish-on-save t))