Skip to content

Instantly share code, notes, and snippets.

@jbpotonnier
Last active January 3, 2016 12:29
Show Gist options
  • Save jbpotonnier/8463631 to your computer and use it in GitHub Desktop.
Save jbpotonnier/8463631 to your computer and use it in GitHub Desktop.
Some tools to use Haskell in a shell pipe. ex: cat stats.dat | hask 'maplines (nth 1 |> to_float) |> maximum'
import Control.Category ((>>>))
let io h = interact $ (++"\n") . show . h
let maplines h = map (h . words) . lines
let to_float = read :: String -> Float
let nth = flip (!!)
let (|>) = (>>>) :: (a -> b) -> (b -> c) -> (a -> c)
hask () {
ghc -e "io \$ $*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment