-
-
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'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hask () { | |
ghc -e "io \$ $*" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment