@@ -9,6 +9,57 @@ This is part of the [[file:starter-kit.org][Emacs Starter Kit]].
9
9
:END:
10
10
Support for editing Haskell
11
11
12
+ ** Setting up cabal
13
+ You can skip these steps if you've already setup ghc and cabal
14
+ *** Install cabal
15
+ **** Linux (Debian/Ubuntu)
16
+ #+begin_src sh
17
+ sudo apt-get update
18
+ sudo apt-get install ghc cabal-install
19
+ cabal update
20
+ #+end_src
21
+
22
+ **** OS X [with Homebrew]
23
+ #+begin_src sh
24
+ brew update
25
+ brew install ghc cabal-install
26
+ cabal update
27
+ #+end_src
28
+
29
+ *** Update cabal
30
+ #+start_src sh
31
+ cabal install cabal-install
32
+ #+end
33
+
34
+ *** Set path to ~/.cabal/bin
35
+ #+begin_src sh
36
+ echo 'PATH=~/.cabal/bin:$PATH'|tee -a ~/.profile
37
+ source ~/.profile
38
+ which cabal
39
+ #+end_src
40
+
41
+ The last line should show you that you are now using the local and
42
+ latest version of cabal located in your ~/.cabal/bin directory.
43
+
44
+ *** Innstall Packages for Development
45
+
46
+ Haskell modes usually have two components to them. One side is haskell
47
+ and the other side is installed and configured in Emacs
48
+
49
+ We will want to install some basic haskell packages in our ~/.cabal &
50
+ ~/.ghc user directories. This makes them available along side cabal
51
+ for doing development on your projects.
52
+
53
+ Running those commands in the shell might take some time - emacs
54
+ appears to be frozen; trust me, it's not
55
+ #+begin_src sh
56
+ cabal install happy alex ;# needed but not listed as dependency
57
+ #+end_src
58
+
59
+ Paste the following into your terminal:
60
+
61
+
62
+ ** Pretty lambdas
12
63
pretty lambdas in Haskell code
13
64
#+begin_src emacs-lisp
14
65
(defun pretty-lambdas-haskell ()
@@ -19,9 +70,98 @@ pretty lambdas in Haskell code
19
70
nil))))))
20
71
#+end_src
21
72
22
- Haskell mode hook
73
+
74
+ ** Haskell Mode
75
+ *** Install Haskell mode
76
+ #+begin_src emacs-lisp
77
+ (starter-kit-install-if-needed 'haskell-mode)
78
+ #+end_src
79
+
80
+ *** Configure
23
81
#+begin_src emacs-lisp
24
82
(add-hook 'haskell-mode-hook 'run-starter-kit-coding-hook)
25
83
(when (window-system)
26
84
(add-hook 'haskell-mode-hook 'pretty-lambdas-haskell))
85
+ (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
86
+ ;; Ignore compiled Haskell files in filename completions
87
+ (add-to-list 'completion-ignored-extensions ".hi")
88
+ #+end_src
89
+
90
+
91
+ ** Stylish Haskell
92
+ A simple Haskell code prettifier.
93
+
94
+ This tool tries to help where necessary without getting in the way.
95
+
96
+ *Features*
97
+
98
+ - Aligns and sorts import statements
99
+ - Groups and wraps {-# LANGUAGE #-} pragmas, can remove (some)
100
+ redundant pragmas
101
+ - Removes trailing whitespace
102
+ - Replaces tabs by four spaces (turned off by default)
103
+ - Replaces some ASCII sequences by their Unicode equivalents (turned
104
+ off by default)
105
+
106
+ #+begin_src sh
107
+ cabal install stylish-haskell
108
+ #+end_src
109
+ *** Configuration
110
+ To call it for every save, make sure you have C-x C-s rebound to
111
+ haskell-mode-save-buffer.
112
+
113
+ #+begin_src emacs-lisp
114
+ (defadvice haskell-mode-stylish-buffer (around skip-if-flycheck-errors activate)
115
+ (unless (flycheck-has-current-errors-p 'error)
116
+ ad-do-it))
117
+ (setq haskell-stylish-on-save t)
118
+ #+end_src
119
+
120
+ ** GHC mod
121
+ The ghc-mod command is a backend command to enrich Haskell programming
122
+ on editors including Emacs, Vim, and Sublime.
123
+ *** Install ghc-mod
124
+ #+begin_src sh
125
+ cabal install ghc-mod
126
+ #+end_src
127
+ #+begin_src emacs-lisp
128
+ (starter-kit-install-if-needed 'ghc)
129
+ #+end_src
130
+
131
+
132
+ ** Structured Haskell
133
+ This minor mode provides structured editing operations based on the
134
+ syntax of Haskell. In short-hand it's called SHM and throughout the
135
+ codebase, too. It acts a bit like, and is heavily inspired by,
136
+ paredit-mode for Emacs.
137
+
138
+ *** Install structured Haskell
139
+ #+begin_src sh
140
+ cabal install structured-haskell
141
+ #+end_src
142
+ #+begin_src emacs-lisp
143
+ (starter-kit-install-if-needed 'shm)
144
+ #+end_src
145
+
146
+ *** Configure
147
+ #+begin_src emacs-lisp
148
+ (add-hook 'haskell-mode-hook 'structured-haskell-mode)
149
+ ;; The following are apparently pretty good for solarized-light.
150
+ ;;(set-face-background 'shm-current-face "#eee8d5")
151
+ ;;(set-face-background 'shm-quarantine-face "lemonchiffon")
152
+ #+end_src
153
+
154
+
155
+ ** Installing Haskell-Mode Extensions
156
+ *** Install flycheck
157
+ #+begin_src emacs-lisp
158
+ (starter-kit-install-if-needed 'flycheck)
159
+ (add-hook 'flycheck-mode-hook #'flycheck-haskell-setup)
160
+ (global-flycheck-mode)
161
+ #+end_src
162
+ *** Install flyspell-haskell
163
+ #+begin_src emacs-lisp
164
+ (starter-kit-install-if-needed 'flyspell)
165
+ (add-hook 'haskell-mode-hook 'flyspell-prog-mode)
27
166
#+end_src
167
+
0 commit comments