(defun hlint-refactor-call-process-region-checked (start end program &optional args) "Send text from START to END to PROGRAM with ARGS. This is a wrapper around `call-process-region' that doesn't replace the region with the output of PROGRAM if it returned a non-zero exit code." (let ((exit (apply 'call-process-region start end program ; name of program t; delete region t; send output to buffer nil; no redisplay during output args ))) (unless (eq exit 0) (primitive-undo1 buffer-undo-list))))
(defun hlint-refactor-call-process-region-preserve-point (start end program &optional args) "Send text from START to END to PROGRAM with ARGS preserving the point. This uses `call-process-region-checked' internally." (let ((line (line-number-at-pos)) (column (current-column))) (hlint-refactor-call-process-region-checked start end program args) (goto-line line) (move-to-column column)))
;;;###autoload (defun hlint-refactor-refactor-buffer (&optional args) "Apply all hlint suggestions in the current buffer. ARGS specifies additional arguments that are passed to hlint." (interactive) (hlint-refactor-call-process-region-preserve-point (point-min) (point-max) "hlint" (append '("--refactor" "-") args)))
;;;###autoload (defun hlint-refactor-refactor-at-point () "Apply the hlint suggestion at point." (interactive) (let ((col (number-to-string (+1 (current-column)))) (line (number-to-string (line-number-at-pos)))) (hlint-refactor-refactor-buffer (list (concat"--refactor-options=--pos " line "," col)))))
;after how many letters do we want to get completion tips? 1 means from the first letter (setq company-minimum-prefix-length 1) (setq company-dabbrev-downcase 0) ;after how long of no keys should we get the completion tips? in seconds (setq company-idle-delay 0.1)
(add-hook 'haskell-mode-hook 'my-haskell-hook) (setq dante-repl-command-line '("stack""repl" dante-target)) ;; Put following line in your project: .dir-locals.el ;; ((nil . ((dante-methods . (stack)))))
;; use M-. on a name in a Haskell buffer which will jump directly to its definition (setq haskell-tags-on-save t)
(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(haskell-stylish-on-save t) '(package-selected-packages (quote (auto-complete merlin utop tuareg hasky-stack exec-path-from-shell haskell-mode flycheck company))))
总结
效果如下图所示,hlint代码建议:
代码补全,有了intero可以不需要ghc-mod:
2019年补充
Visual Studio Code可以说已经取代了曾经Atom的地位,而且随着生态的不断完善已经可以胜任基本的开发工作。有一种可以说「一键式」的开发环境就是利用Haskell Language Server搭配任意你喜欢的Editor。这里我配置了一个VS Code的环境,HIE相对来讲配置简单,可以参考官方指南。相比于我自己的配置,最明显的多了HaRe和LiquidHaskell两个神器,这些全部配套起来再加上stack ghci完全可以作为胜任生产环境的工业级的IDE。使用效果: