Skip to content

Instantly share code, notes, and snippets.

@imeckler
Last active October 12, 2017 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imeckler/5376166 to your computer and use it in GitHub Desktop.
Save imeckler/5376166 to your computer and use it in GitHub Desktop.
Haskell pipeline
{-# LANGUAGE GADTs #-}
import Data.Char (digitToInt)
data Nil
data Cons a b
data Pipeline ts a c where
(:>) :: (a -> b) -> Pipeline ts b c -> Pipeline (Cons (a -> b) ts) a c
Id :: Pipeline Nil t t
infixr 9 :>
pHead :: Pipeline (Cons (a -> b) fs) a c -> (a -> b)
pHead (f :> _) = f
pTail :: Pipeline (Cons (a -> b) fs) a c -> Pipeline fs b c
pTail (_ :> fs) = fs
testP = digitToInt :> (+ 1) :> show :> Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment