What is the least painful way to get Haskell and a modern, user-friendly development environment set up ?Based on my periodic attempts to set up the available Haskell IDEs, and to support newcomers on IRC,as of early 2016 it's stack and Atom(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).
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.They briefly note the steps required, and also the results you can expect (something that's often unclear with Haskell IDEs).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.With a fast connection/machine and the hints below, it should take less than half an hour, most of that unattended.
This doc can evolve if you test it yourself and send pull requests (quick feedback via IRC is also welcome).Note as of late 2016 I have moved from Atom to Intellij (similar features, more refined and robust)and I've stopped updating this doc myself.
If it is obsolete or there's a much better place for it, let me know.I hope you find it useful.
Url: https://github.com/simonmichael/haskell-atom-setup
Created: 2016/5/12 by Simon Michael (email:[email protected], freenode:sm)
Updated: 2016/12/26
Discussion: #haskell, issues, haskell-cafe list
Created: 2016/5/12 by Simon Michael (email:[email protected], freenode:sm)
Updated: 2016/12/26
Discussion: #haskell, issues, haskell-cafe list
On OSX 10.6.7 (using the Haskell Platform /w GHC 7.0.2) I could load your built shared. Glfw/lib/tga.c - glfw/lib/thread.c - glfw/lib/time.c - glfw/lib/window.c + + if.
Table of Contents
Set up Haskell
- Install
Stack
, (Haskell build tool): http://haskell-lang.org/get-started - Add
Stack
's bin directory to your PATH if possible.
- Eg:
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
- Install a default instance of GHC (Haskell compiler) for your user:
stack setup
Create a minimal program in terminal (Optional)
in a terminal/command/shell window:
Test your program interactively in terminal (Optional)
Set up Atom
- install tools:
stack install ghc-mod hlint stylish-haskell # slow
- install Atom (text editor & IDE): http://atom.io
- start Atom
- install plugins:
Atom Preferences
->Install
search for haskell
- install
language-haskell
,ide-haskell
,ide-haskell-repl
andhaskell-ghc-mod
- install
search for term3
- install
term3
- install
- configure plugins:
Atom Preferences
->Packagages
ide-haskell
- nothing ?
ide-haskell-repl
Command Args
:ghci
Command Path
:stack
# or the stack executable's absolute path, eg /usr/local/bin/stack. Don't use ~.
haskell-ghc-mod
Additional Path Directories
: ... # eg on mac: /Users/USERNAME/.local/bin, /usr/local/bin
View your program in Atom
File
->Open
, selecthello.hs
(or other file you like)Haskell IDE
->Toggle Panel
hides/showsError/Warning/Lint/...
panes
With an module open, you should see:
- Syntax or type errors highlighted in place and reported in the
Error
pane - Hhlint cleanup suggestions highlighted in place and reported in the
Lint
pane - Auto-completion when typing both Haskell keywords (
module
,let
, etc) and local names
Troubleshooting
Haskell IDE
->Prettify
gives an error:stylish-haskell
may not be in your path if Atom was started from GUI. Try starting from terminal (on mac: open -a Atom)- The file parsing failed due to, for example, misplaced code
- if
Haskell IDE
->Prettify
does nothing, chances are it is already prettified
Test your program interactively in Atom
While viewing
hello.hs
, do Haskell IDE
-> Open REPL
and after you should see a new pane with a *Main>
prompt.Enter GHCI commands here using CTRL-enter or CMD-enter:
:main # or any Haskell expression
:reload # after saving changes in hello.hs
:help
:quit
Run terminal commands in Atom
You can also run regular GHCI in a terminal pane:
Packages
-> Term 3
-> Open New Terminal In Right Pane
(eg)Create a program, package and project
- In the terminal:
stack new hello simple
- In Atom:
File
->Open
, select and open thehello
directory (with no file selected)
You should see:, in the sidebar:
Build/run/install your package
In the terminal:
More on Atom's Haskell support
- If errors are not highlighted in open files on starting Atom
File
->Save
will wake it up (haskell-ghc-mod/#142)
- If errors are reported but the file compiles without error at the command line
- in multi-package stack projects, haskell-ghc-mod (ghc-mod) requires a workaround (ghc-mod/#787)
- see also https://github.com/DanielG/ghc-mod/wiki for other possible causes
Stack is a cross-platform program for developing Haskellprojects. It is aimed at Haskellers both new and experienced.
It features:
- Installing GHC automatically, in an isolated location.
- Installing packages needed for your project.
- Building your project.
- Testing your project.
- Benchmarking your project.
How to install¶
For most Un*x operating systems, the easiest way to install is to run:
or:
On Windows, you can download and install theWindows 64-bit Installer.
For other operating systems and direct downloads, check out theinstall and upgrade guide.
Note that the get.haskellstack.orgscript will ask for root access using
sudo
in order to use yourplatform's package manager to install dependencies and to install to/usr/local/bin
. If you prefer more control, follow the manualinstallation instructions in theinstall and upgrade guide.How to upgrade¶
If you already have
stack
installed, upgrade it to the latest versionby running:Quick Start Guide¶
First you need to install it (see previous section).
Start your new project:¶
- The
stack new
command will create a new directory containing all the needed files to start a project correctly. - The
stack setup
will download the compiler if necessary in an isolated location (default~/.stack
) that won't interfere with any system-level installations. (For information on installation paths, please use thestack path
command.). - The
stack build
command will build the minimal project. stack exec my-project-exe
will execute the command.- If you just want to install an executable using stack, then all you have to do is
stack install <package-name>
.
If you want to launch a REPL:
Run
stack
for a complete list of commands.Workflow¶
The
stack new
command should have created the following files:So to manage your library:
- Edit files in the
src/
directory.
The
app
directory should preferably contain only files related to executables.- If you need to include another library (for example the package
text
): - Add the package
text
to the filepackage.yaml
in the sectiondependencies: ...
. - Run
stack build
another time. stack build
will update my-project.cabal for you. If desired you can update the .cabal file manually and stack will use .cabal instead of package.yaml.- If you get an error that tells you your package isn't in the LTS. Just try to add a new version in the
stack.yaml
file in theextra-deps
section.
That was a really fast introduction on how to start to code in Haskell using
stack
.If you want to go further, we highly recommend you to read the stack
guide.How to contribute¶
This assumes that you have already installed a version of stack, and have
git
installed.- Clone
stack
from git withgit clone https://github.com/commercialhaskell/stack.git
. - Enter into the stack folder with
cd stack
. - Build
stack
using a pre-existingstack
install withstack setup && stack build
. - Once
stack
finishes building, check the stack version withstack exec stack -- --version
. Make sure the version is the latest. - Look for issues tagged with newcomer friendly and awaiting pull request labels.
Build from source as a one-liner:
If you need to check your changes quickly run:
This allows you to set a special stack root (instead of
~/.stack/
or, onWindows, %LOCALAPPDATA%Programsstack
) and to target your commands at aparticular stack.yaml
instead of the one found in the current directory.Complete guide to stack¶
This repository also contains a complete user guide to usingstack, covering all of the most common use cases.
Questions, Feedback, Discussion¶
- For frequently asked questions about detailed or specific use-cases, please see the FAQ.
- For general questions, comments, feedback and support, please write to the stack mailing list.
- For bugs, issues, or requests, please open an issue.
- When using Stack Overflow, please use the haskell-stack tag.
Why Stack?¶
Stack is a build tool for Haskell designed to answer the needs ofHaskell users new and experienced alike. It has a strong focus onreproducible build plans, multi-package projects, and a consistent,easy-to-learn interface, while providing the customizability andpower experienced developers need. As a build tool, Stack does notstand alone. It is built on the great work provided by:
- The Glasgow Haskell Compiler (GHC), the premier Haskell compiler. Stack will manage your GHC installations and automatically select the appropriate compiler version for your project.
- The Cabal build system, a specification for defining Haskell packages, together with a library for performing builds.
- The Hackage package repository, providing more than ten thousand open source libraries and applications to help you get your work done.
- The Stackage package collection, a curated set of packages from Hackage which are regularly tested for compatibility. Stack defaults to using Stackage package sets to avoid dependency problems.
Stack is provided by a team of volunteers and companies under theauspices of the Commercial Haskellgroup. The project was spearheaded byFP Complete to answer the needs ofcommercial Haskell users, and has since become a thriving open sourceproject meeting the needs of Haskell users of all stripes.
If you'd like to get involved with Stack, check out thenewcomer friendlylabel on the Github issue tracker.
How to uninstall¶
Removing
~/.stack
and /usr/local/bin/stack
should be sufficient. You may want to delete .stack-work
folders in any Haskell projects that you have built.