docs(haskell): rewrite readme
A lot of it was outdated, and now it conforms to the readme template.
This commit is contained in:
parent
a20cd88e8e
commit
d1555257a8
1 changed files with 36 additions and 93 deletions
|
@ -5,126 +5,69 @@
|
|||
|
||||
* Table of Contents :TOC:
|
||||
- [[#description][Description]]
|
||||
- [[#external-resources][External resources]]
|
||||
- [[#maintainers][Maintainers]]
|
||||
- [[#module-flags][Module Flags]]
|
||||
- [[#plugins][Plugins]]
|
||||
- [[#prerequisites][Prerequisites]]
|
||||
- [[#cabal][Cabal]]
|
||||
- [[#lsp-haskell-language-server][LSP (haskell-language-server)]]
|
||||
- [[#stack][Stack]]
|
||||
- [[#haskell-packages][Haskell packages]]
|
||||
- [[#features][Features]]
|
||||
- [[#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 LSP
|
||||
(haskell-language-server).
|
||||
Adds Haskell support to Doom Emacs.
|
||||
|
||||
+ Code completion (~company-ghc~)
|
||||
+ Look up documentation (~hoogle~)
|
||||
+ REPL (~ghci~)
|
||||
+ Syntax-checking (~flycheck~)
|
||||
+ [[https://github.com/hlissner/doom-snippets/tree/master/haskell-mode][Snippets]]
|
||||
** Maintainers
|
||||
This module has no dedicated maintainers.
|
||||
|
||||
** External resources
|
||||
Here are a few resources I've found indispensable 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
|
||||
+ =+lsp= Enables LSP support with haskell-language-server (requires the ~:tools lsp~ module).
|
||||
+ =+lsp= Enable LSP support with for [[https://github.com/haskell/haskell-language-server][haskell-language-server]] (requires the =:tools lsp= module).
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/haskell/haskell-mode][haskell-mode]]
|
||||
+ =+lsp=
|
||||
+ [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]]
|
||||
+ [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]] (=+lsp=, =:tools lsp=)
|
||||
|
||||
* Prerequisites
|
||||
It is recommended to install the haskell tooling using [[https://www.haskell.org/ghcup/][ghcup]]. Only ghc is needed
|
||||
for basic functionality:
|
||||
|
||||
+ LSP users need the =haskell-language-server= LSP server
|
||||
+ All users will need the =hoogle= package
|
||||
|
||||
** Cabal
|
||||
*** MacOS
|
||||
#+BEGIN_SRC sh
|
||||
brew install cabal-install ghc
|
||||
#+BEGIN_SRC bash
|
||||
ghcup install ghc
|
||||
#+END_SRC
|
||||
|
||||
*** Arch Linux
|
||||
#+BEGIN_SRC sh
|
||||
sudo pacman -S cabal-install ghc
|
||||
#+END_SRC
|
||||
|
||||
*** openSUSE
|
||||
#+BEGIN_SRC sh :dir /sudo::
|
||||
sudo zypper install cabal-install ghc
|
||||
#+END_SRC
|
||||
|
||||
** LSP (haskell-language-server)
|
||||
You will need =stack= and =git= installed.
|
||||
|
||||
You will find a comprehensive [[https://github.com/haskell/haskell-language-server#installation][instructions for haskell-language-server on its project page]], but if you are using [[https://www.haskell.org/ghcup/][ghcup]]:
|
||||
but =+lsp= users should also install the language server:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
ghcup install hls
|
||||
#+END_SRC
|
||||
|
||||
** Stack
|
||||
To use LSP, you need =stack=:
|
||||
Installing [[https://www.haskell.org/cabal/][cabal]] or [[https://docs.haskellstack.org/en/stable/README/][stack]] as well is recommended, and can be done through
|
||||
=ghcup=.
|
||||
|
||||
*** 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
|
||||
=haskell-mode= provides support for [[https://github.com/ndmitchell/hoogle][hoogle]], which can be installed through
|
||||
system package manager, cabal, or stack.
|
||||
|
||||
*** openSUSE
|
||||
#+BEGIN_SRC sh :dir /sudo::
|
||||
sudo zypper install stack
|
||||
stack setup
|
||||
#+END_SRC
|
||||
=haskell-language-server= provides support for [[https://github.com/ndmitchell/hlint/][hlint]], and haskell code
|
||||
formatters such as [[https://github.com/lspitzner/brittany][brittany]], [[https://github.com/ennocramer/floskell][floskell]], [[https://github.com/tweag/ormolu][ormolu]], [[https://github.com/fourmolu/fourmolu][fourmolu]], and [[https://github.com/haskell/stylish-haskell][stylish-haskell]],
|
||||
which can be installed through system package manager, cabal, or stack.
|
||||
|
||||
** Haskell packages
|
||||
You'll need to install the following packages using ~stack~ or ~cabal~:
|
||||
* Features
|
||||
This module intergrates the haskell packages into Doom by providing things such
|
||||
as repl support, project root recognition, etc. It also provide the following
|
||||
keybindings:
|
||||
|
||||
+ =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
|
||||
| Keybinding | Description |
|
||||
|-------------------+-----------------------------------------------|
|
||||
| =<localleader> b= | Build the current cabal project |
|
||||
| =<localleader> c= | Visit the =.cabal= file of the current buffer |
|
||||
| =<localleader> h= | Toggle visibility of the form at point |
|
||||
| =<localleader> H= | hides all top level functions |
|
||||
|
||||
* 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:
|
||||
After installing your preferred formatter, make sure to set
|
||||
=lsp-haskell-formatting-provider= to it.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq haskell-process-type 'cabal-new-repl)
|
||||
Make sure to configure the lsp to use your perfered formatter, e.g.:
|
||||
#+BEGIN_SRC elisp
|
||||
;; ~/.doom.d/config.el
|
||||
(after!
|
||||
(setq lsp-haskell-formatting-provider "brittany"))
|
||||
#+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]].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue