haskellscript: Command line tool for running Haskell scripts with a hashbang.
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.
Examples
Print out JSON constructed with Aeson
https://github.com/seanparsons/haskellscript/blob/master/Example.hs
Lookup weather for your current IP address
https://github.com/seanparsons/haskellscript/blob/master/WeatherExample.hs
Prerequisites
A sandbox capable install of Cabal.
Howto
The script falls into three main parts:
The hashbang first line:
#!/usr/bin/env haskellscript
Dependencies (potentially including versions):
--#aeson
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.
Downloads
- haskellscript-0.2.3.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.1, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.2.2, 0.2.3 |
---|---|
Dependencies | base (>=4.6 && <4.9), cryptohash, directory, either, filepath, mtl, process, text [details] |
License | BSD-3-Clause |
Copyright | Copyright (C) 2015 Sean Parsons |
Author | Sean Parsons |
Maintainer | github@futurenotfound.com |
Category | Development |
Home page | http://github.com/seanparsons/haskellscript/ |
Bug tracker | http://github.com/seanparsons/haskellscript/issues |
Source repo | head: git clone git://github.com/seanparsons/haskellscript.git |
Uploaded | by seanparsons at 2015-05-28T21:58:36Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Executables | haskellscript |
Downloads | 4588 total (3 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs not available [build log] Last success reported on 2015-11-12 [all 7 reports] |