├── Makefile
├── README.md
└── local.tmpl.html
/Makefile:
--------------------------------------------------------------------------------
1 | README.html html: README.md local.tmpl.html
2 | pandoc -f markdown \
3 | --template local.tmpl.html README.md -o README.html
4 |
5 | liverender:
6 | fswatch -l 0.1 -0 *.{md,tmpl.*} | xargs -0 -n1 -I{} make html
7 |
8 | livereload:
9 | livereloadx -p 10002 --static .
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | [2020: obsolete, use VS Code instead]
3 |
4 |
5 | # Haskell Atom Setup 2016
6 |
7 | What is the least painful way to get Haskell and a modern, user-friendly development environment set up ?
8 | Based on my periodic attempts to set up the available Haskell IDEs, and to support newcomers on IRC,
9 | as of early 2016 it's [stack](http://haskellstack.org) and [Atom](http://atom.io)
10 | (unless you're on a mac and willing to pay and be in a slightly walled garden, in which case it's [Haskell for Mac](http://haskellformac.com)).
11 |
12 | Here are some basic recipes for setting up Haskell and Atom from scratch, on any of the major platforms, as reliably and easily as possible.
13 | They briefly note the steps required, and also the results you can expect (something that's often unclear with Haskell IDEs).
14 | You don't need any previous Haskell knowledge, but you will need to download things, run terminal commands, wait for builds, edit files and configure settings.
15 | With a fast connection/machine and the hints below, it should take less than half an hour, most of that unattended.
16 |
17 | This doc can evolve if you test it yourself and send pull requests (quick feedback via IRC is also welcome).
18 | Note as of late 2016 I have moved from Atom to Intellij (similar features, more refined and robust)
19 | and I've stopped updating this doc myself.
20 |
21 | If it is obsolete or there's a much better place for it, let me know.
22 | I hope you find it useful.
23 |
24 | Url:
25 | Created: 2016/5/12 by Simon Michael (email:, freenode:sm)
26 | Updated: 2016/12/26
27 | Discussion: [#haskell](http://webchat.freenode.net/?channels=haskell), [issues](https://github.com/simonmichael/haskell-atom-setup/issues), haskell-cafe list
28 |
29 |
30 |
31 | **Table of Contents**
32 |
33 | - [Set up Haskell](#set-up-haskell)
34 | - [Create a minimal program in terminal](#create-a-minimal-program-in-terminal)
35 | - [Test your program interactively in terminal](#test-your-program-interactively-in-terminal)
36 | - [Set up Atom](#set-up-atom)
37 | - [View your program in Atom](#view-your-program-in-atom)
38 | - [Test your program interactively in Atom](#test-your-program-interactively-in-atom)
39 | - [Run terminal commands in Atom](#run-terminal-commands-in-atom)
40 | - [Create a program, package and project](#create-a-program-package-and-project)
41 | - [Build/run/install your package](#buildruninstall-your-package)
42 | - [More on Atom's Haskell support](#more-on-atoms-haskell-support)
43 |
44 |
45 |
46 | ## Set up Haskell
47 | 1. Install `Stack`, (Haskell build tool):
48 | 2. Add `Stack`'s bin directory to your PATH if possible.
49 | * Eg: `echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc`
50 | 3. Install a default instance of GHC (Haskell compiler) for your user:
51 | * `stack setup`
52 |
53 | ### Create a minimal program in terminal (Optional)
54 | in a terminal/command/shell window:
55 | ```
56 | echo 'main = putStrLn "hello world"' > hello.hs
57 | stack ghc hello.hs # compile the program
58 | ./hello # run it
59 | ```
60 |
61 | ### Test your program interactively in terminal (Optional)
62 | ```
63 | stack ghci
64 | :load hello.hs
65 | :main # or any Haskell expression
66 | :reload # after changing hello.hs
67 | :help
68 | :quit
69 | ```
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | ## Set up Atom
82 | 1. install tools: `stack install ghc-mod hlint stylish-haskell # slow`
83 | 2. install Atom (text editor & IDE):
84 | 3. start Atom
85 | 4. install plugins: `Atom Preferences` -> `Install`
86 | * `search for haskell`
87 | - install `language-haskell`, `ide-haskell`, `ide-haskell-repl` and `haskell-ghc-mod`
88 |
89 | * `search for term3`
90 | - install `term3`
91 |
92 | 5. configure plugins: `Atom Preferences` -> `Packagages`
93 | * `ide-haskell`
94 | - nothing ?
95 | * `ide-haskell-repl`
96 | - `Command Args`: `ghci`
97 | - `Command Path`: `stack` # or the stack executable's absolute path, eg /usr/local/bin/stack. Don't use ~.
98 | * `haskell-ghc-mod`
99 | - `Additional Path Directories`: ... # eg on mac: /Users/USERNAME/.local/bin, /usr/local/bin
100 |
101 | ### View your program in Atom
102 | 1. `File` -> `Open`, select `hello.hs` (or other file you like)
103 | 2. `Haskell IDE` -> `Toggle Panel` hides/shows `Error/Warning/Lint/...` panes
104 |
105 | **With an module open, you should see:**
106 | * Syntax or type errors highlighted in place and reported in the `Error` pane
107 | * Hhlint cleanup suggestions highlighted in place and reported in the `Lint` pane
108 | * Auto-completion when typing both Haskell keywords (`module`, `let`, etc) and local names
109 |
110 | #### Troubleshooting
111 | * `Haskell IDE` -> `Prettify` gives an error:
112 | * `stylish-haskell` may not be in your path if Atom was started from GUI. Try starting from terminal (on mac: open -a Atom)
113 | * The file parsing failed due to, for example, misplaced code
114 |
115 | * if `Haskell IDE` -> `Prettify` does nothing, chances are it is already prettified
116 |
117 | ### Test your program interactively in Atom
118 | While viewing `hello.hs`, do `Haskell IDE` -> `Open REPL` and after you should see a new pane with a `\*Main>` prompt.
119 |
120 | Enter GHCI commands here using CTRL-enter or CMD-enter:
121 |
122 | `:main # or any Haskell expression`
123 | `:reload # after saving changes in hello.hs`
124 | `:help`
125 | `:quit`
126 |
127 | ### Run terminal commands in Atom
128 | You can also run regular GHCI in a terminal pane:
129 |
130 | `Packages` -> `Term 3` -> `Open New Terminal In Right Pane` (eg)
131 |
132 | ## Create a program, package and project
133 |
134 | * In the terminal: `stack new hello simple`
135 | * In Atom: `File` -> `Open`, select and open the `hello` directory (with no file selected)
136 |
137 | **You should see:**, in the sidebar:
138 | ```
139 | .stack-work
140 | src/
141 | Main.hs # new program, similar to hello.hs. Click to open it
142 | hello.cabal # package & program properties
143 | LICENSE
144 | Setup.hs
145 | stack.yaml # project properties
146 | ```
147 |
148 | ## Build/run/install your package
149 |
150 | In the terminal:
151 |
152 | ```
153 | cd hello # enter the project directory (if necessary)
154 | stack build # build this project's program(s)
155 | stack exec -- hello # run this project's hello program in place
156 | stack install # install the hello program in ~/.local/bin
157 | (%USERPROFILE%\.local\bin on Windows)
158 | cd; hello # runs the installed hello program, if your PATH is set right (see setup)
159 | ```
160 |
161 | ## More on Atom's Haskell support
162 |
163 | * If errors are not highlighted in open files on starting Atom
164 | * `File` -> `Save` will wake it up ([haskell-ghc-mod/#142](https://github.com/atom-haskell/haskell-ghc-mod/issues/142))
165 | * If errors are reported but the file compiles without error at the command line
166 | * in multi-package stack projects, haskell-ghc-mod (ghc-mod) requires a workaround ([ghc-mod/#787](https://github.com/DanielG/ghc-mod/issues/787))
167 | * see also for other possible causes
168 |
--------------------------------------------------------------------------------
/local.tmpl.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | $body$
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------