Skip to content

Instantly share code, notes, and snippets.

@pbrisbin
Created July 20, 2014 17:10
Show Gist options
  • Select an option

  • Save pbrisbin/21b5bbb3a22dafe3caf9 to your computer and use it in GitHub Desktop.

Select an option

Save pbrisbin/21b5bbb3a22dafe3caf9 to your computer and use it in GitHub Desktop.
End-to-end development of a Haskell project

Prerequisites: GHC + cabal-install

Setup project skeleton using hi and my template:

% cabal update
% cabal install hi
% hi \
    --module-name "Foo.Bar" \
    --package-name "foo" \
    --author 'Your Name' \
    --email 'your@email.com' \
    --repository gh:pbrisbin/hi-hspec

Create a sandbox and install dependencies:

% cd foo
% cabal sandbox init
% cabal install --enable-tests --dependencies-only -j4

Setup and work with your first spec:

% vim test/Foo/BarSpec.hs
% cabal exec ghci test/Foo/BarSpec.hs  # compile single spec
                                       # run :reload to re-compile
                                       # run :main to execute test

Directly run a single (spec) file, useful as an editor hot-key:

% echo ':main' | cabal exec ghci -v0 test/Foo/BarSpec.hs

Implement:

% vim src/Foo/Bar.hs

Run all tests:

% cabal test

Modify package information (description, dependencies, version), etc:

% vim foo.cabal

Build a source distribution file (tarball):

% cabal sdist

Upload it to Hackage (requires account):

% cabal upload dist/foo-0.0.1.tar.gz

Install it from somewhere else

% cabal update
% cabal install foo

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment