Command line tool for running Haskell scripts with a hashbang. http://github.com/seanparsons/haskellscript/

Latest on Hackage:0.2.3

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Sean Parsons

This tool provides the ability to script in a shell with Haskell (including dependencies) the same way that has been possible with bash scripts or Python.


Print out JSON constructed with Aeson


Lookup weather for your current IP address



A sandbox capable install of Cabal.


The script falls into three main parts:

  • The hashbang first line:

#!/usr/bin/env haskellscript
  • Dependencies (potentially including versions):

  • The code:

import Data.Aeson
import Data.ByteString.Lazy hiding (putStrLn, unpack)
import Data.Text
import Data.Text.Encoding
jsonExample = object ["Test" .= True, "Example" .= True]
main = putStrLn $ unpack $ decodeUtf8 $ toStrict $ encode jsonExample

Note that because the dependencies specified are hashed to enable re-use it's worth specifying exact versions across multiple scripts to prevent the version used being quite old after a while.

Depends on 8 packages:
Used by 1 package:
comments powered byDisqus