diff --git a/modules/lang/haskell/+dante.el b/modules/lang/haskell/+dante.el index 44908bc9a..2774b8a62 100644 --- a/modules/lang/haskell/+dante.el +++ b/modules/lang/haskell/+dante.el @@ -20,7 +20,7 @@ (set-company-backend! 'dante-mode #'dante-company) (defun +haskell*restore-modified-state (orig-fn &rest args) - "Dante quietly saves the current buffer (without triggering save hooks) before + "Dante quietly saves the current buffer (without triggering save hooks) before invoking flycheck, unexpectedly leaving the buffer in an unmodified state. This is annoying if we depend on save hooks to do work on the buffer (like reformatting), so we restore a (false) modified state." diff --git a/modules/lang/haskell/+lsp.el b/modules/lang/haskell/+lsp.el index 71967a30b..576e26e67 100644 --- a/modules/lang/haskell/+lsp.el +++ b/modules/lang/haskell/+lsp.el @@ -4,5 +4,7 @@ :after haskell-mode :init (add-hook 'haskell-mode-hook #'lsp!) :config + (when IS-MAC + (setq lsp-haskell-process-path-hie "hie-wrapper")) ;; Does some strange indentation if it pastes in the snippet (setq-hook! 'haskell-mode-hook yas-indent-line 'fixed)) diff --git a/modules/lang/haskell/README.org b/modules/lang/haskell/README.org index f29b189e2..9f8fe77e6 100644 --- a/modules/lang/haskell/README.org +++ b/modules/lang/haskell/README.org @@ -1,6 +1,25 @@ -#+TITLE: :lang haskell +#+TITLE: lang/haskell +#+DATE: January 16, 2017 +#+SINCE: v0.7 +#+STARTUP: inlineimages -This module adds [[https://www.haskell.org/][Haskell]] support, powered by either [[https://haskell-lang.org/intero][intero]] (the default) or [[https://github.com/jyp/dante][dante]]. +* Table of Contents :TOC: +- [[#description][Description]] + - [[#external-resources][External resources]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] + - [[#stack][Stack]] + - [[#cabal][Cabal]] + - [[#lsp][LSP]] + - [[#haskell-packages][Haskell packages]] +- [[#configuration][Configuration]] + - [[#using-the-new-style-cabal-repl][Using the new-style cabal REPL]] +- [[#troubleshooting][Troubleshooting]] + +* Description +This module adds [[https://www.haskell.org/][Haskell]] support, powered by either [[https://haskell-lang.org/intero][intero]] (the default), [[https://github.com/jyp/dante][dante]] +or [[https://github.com/emacs-lsp/lsp-haskell][LSP]]. + Code completion (~company-ghc~) + Look up documentation (~hoogle~) @@ -10,102 +29,130 @@ This module adds [[https://www.haskell.org/][Haskell]] support, powered by eithe + Code navigation (~dante~) + [[https://github.com/hlissner/emacs-snippets/tree/master/haskell-mode][Snippets]] -#+begin_quote -Haskell contends with C and Ruby as my favorite language. My Haskell code will never save the world, but I'll reach for it for small projects and programming exercises (like projecteuler.com or exercism.io). - -I'd love to incorporate it into my machine learning work, but Python and Julia hold that crown. For now. -#+end_quote - -* Table of Contents :TOC: -- [[#install][Install]] - - [[#intero][Intero]] - - [[#dante][Dante]] -- [[#troubleshooting][Troubleshooting]] -- [[#resources][Resources]] - -* Install -This module has two submodules: *Intero* or *Dante*. To activate one, specify one or the other in your pubilc ~init.el~, e.g.: - -#+BEGIN_SRC emacs-lisp -(doom! :lang (haskell +intero)) -;; or -(doom! :lang (haskell +dante)) -#+END_SRC - -Your dependencies will change slightly, depending on which you choose: - -** Intero -*** Haskell -To get started you must install *stack*: - -**** MacOS -#+BEGIN_SRC sh :tangle (if (doom-system-os 'macos) "yes") -brew install haskell-stack -stack setup -#+END_SRC - -**** Arch Linux -#+BEGIN_SRC sh :dir /sudo:: :tangle (if (doom-system-os 'arch) "yes") -sudo pacman --needed --noconfirm -S stack -# Replace pacaur with your AUR package manager of choice -pacaur --needed --noconfirm -S ncurses5-compat-lib -stack setup -#+END_SRC - -*** External dependencies -This module requires ~ghc-mod~. - -#+BEGIN_SRC sh -stack install ghc-mod -#+END_SRC - -Also ensure that ~\~/.local/bin~ is in ~PATH~: - -#+BEGIN_SRC sh -# place this in your profile file, like ~/.bash_profile or ~/.zshenv -export PATH="~/.local/bin:$PATH" -#+END_SRC - -** Dante -*** Haskell -To get started with Dante and Haskell, you must install cabal - -+ cabal (the haskell package builder) -+ ghc/ghci (the compiler, syntax checker & repl) - -**** MacOS -#+BEGIN_SRC sh -brew install cabal-install ghc -#+END_SRC - -**** Arch Linux -#+BEGIN_SRC sh -sudo pacman --needed --noconfirm -S cabal-install ghc -#+END_SRC - -*** External dependencies -Dante requires ~ghc-mod~ and ~hoogle~: - -#+BEGIN_SRC sh -cabal update -cabal install happy haskell-src-exts # ghc-mod/hoogle dependencies -cabal ghc-mod hoogle -#+END_SRC - -And add Cabal's bin path to $PATH: - -#+BEGIN_SRC sh -export PATH="$HOME/.cabal/bin:$PATH" -#+END_SRC - -* Troubleshooting -+ Stack users: a ~dist/setup-config~ in your project may cause [[ https://github.com/DanielG/ghc-mod/wiki#known-issues-related-to-stack][ghc-mod to not - work]]. - -* Resources +** External resources Here are a few resources I've found indespensible in my Haskell adventures: + [[http://learnyouahaskell.com/][Learn you a haskell for great good]] + [[http://haskellbook.com/][Haskell Programming from first principles]] + [[https://github.com/krispo/awesome-haskell][Awesome Haskell]]: an extensive list of haskell resources + [[https://docs.haskellstack.org/en/stable/README/][The Haskell Tool Stack docs]] + +** Module Flags ++ =+intero= Enables intero; a comprehensive, stack-based development environment + for Haskell. ++ =+dante= Enables dante; a fork of intero aimed at lightweightedness. It + doesn't depend on =stack=, supports both ~cabal~-only and ~stack~ projects, + but lacks eldoc support. ++ =+lsp= Enables lsp-haskell (this requires the ~:tools lsp~ to be enabled). + +** Plugins ++ [[https://github.com/haskell/haskell-mode][haskell-mode]] ++ =+dante= + + [[https://github.com/jyp/dante][dante]] + + [[https://github.com/jyp/attrap][attrap]] ++ =+intero= + + [[https://github.com/chrisdone/intero][intero]] ++ =+lsp= + + [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]] + +* Prerequisites +Depending on whether you use Intero, Dante or LSP, your dependencies will +differ: + ++ Intero and LSP users need =stack= ++ Dante users need =cabal=, =ghc= and =ghc-mod= ++ LSP users need the =haskell-ide-engine= LSP server ++ All users will need the =hoogle= package + +** Stack +To use Intero, you need =stack=: + +*** MacOS +#+BEGIN_SRC sh +brew install haskell-stack +stack setup +#+END_SRC + +*** Arch Linux +#+BEGIN_SRC sh +sudo pacman -S stack +# Replace pacaur with your AUR package manager of choice +pacaur -S ncurses5-compat-lib +stack setup +#+END_SRC + +** Cabal +To use Dante, you need =cabal= (the haskell package builder) and =ghci= (the +compiler, syntax checker & repl): + +*** MacOS +#+BEGIN_SRC sh +brew install cabal-install ghc +#+END_SRC + +*** Arch Linux +#+BEGIN_SRC sh +sudo pacman -S cabal-install ghc +#+END_SRC + +** LSP +You will need =stack= and =git= installed. + +You will find a comprehensive [[https://github.com/haskell/haskell-ide-engine#installation][install guide for haskell-ide-engine on its +project page]], but here's a TL;DR: + +*** MacOS +haskell-ide-engine must be build and installed manually on MacOS, e.g. + +#+BEGIN_SRC emacs-lisp +git clone https://github.com/haskell/haskell-ide-engine +cd haskell-ide-engine +make +#+END_SRC + +*** Arch Linux +=haskell-ide-engine-git= is available on the AUR + +#+BEGIN_SRC emacs-lisp +yay -S haskell-ide-engine-git +#+END_SRC + +** Haskell packages +You'll need to install the following packages using ~stack~ or ~cabal~: + ++ (Dante users) =ghc-mod= + #+BEGIN_SRC sh + stack install ghc-mod + # or + cabal install ghc-mod + #+END_SRC ++ =hoogle= + #+BEGIN_SRC sh + cabal update + cabal install happy haskell-src-exts # ghc-mod/hoogle dependencies + cabal ghc-mod hoogle + # or + stack install ghc-mod + stack install hoogle + #+END_SRC + +And ensure the binaries for these packages are in your ~PATH~, e.g. + +#+BEGIN_SRC sh +# place this in your profile file, like ~/.bash_profile or ~/.zshenv +export PATH="~/.local/bin:$PATH" +#+END_SRC + +* Configuration +** Using the new-style cabal REPL +=haskell-mode= will typically detect what REPL to run based on your project +(e.g. stack, (old-style) cabal or ghc). If you want the new-style cabal REPL you +must set ~haskell-process-type~ manually: + +#+BEGIN_SRC emacs-lisp +(setq haskell-process-type 'cabal-new-repl) +#+END_SRC + +* Troubleshooting ++ Stack users: a ~dist/setup-config~ file in your project may cause [[https://github.com/DanielG/ghc-mod/wiki#known-issues-related-to-stack][ghc-mod to + not work]]. diff --git a/modules/tools/lsp/README.org b/modules/tools/lsp/README.org index d68fde77d..a94b4af7a 100644 --- a/modules/tools/lsp/README.org +++ b/modules/tools/lsp/README.org @@ -33,6 +33,7 @@ As of this writing, these Doom modules possess LSP support: |------------------+---------------------------------------------------------+---------------------------------------------------------------| | [[../../lang/cc/README.org][:lang cc]] | c-mode, c++-mode, objc-mode | ccls | | [[../../lang/go/README.org][:lang go]] | go-mode | go-langserver | +| [[../../lang/haskell/README.org][:lang haskell]] | haskell-mode | haskell-ide-engine | | [[../../lang/javascript/README.org][:lang javascript]] | js2-mode, rjsx-mode, typescript-mode | typescript-language-server | | [[../../lang/java/README.org][:lang java]] | java-mode | lsp-java | | [[../../lang/ocaml/README.org][:lang ocaml]] | taureg-mode | ocaml-language-server |