Skip to content

Instantly share code, notes, and snippets.

@as-capabl as-capabl/builder.hs
Created May 10, 2017

What would you like to do?
module Main where
import Control.Monad.Free.Church
import GHC.Exts (build)
import Control.Monad (forever)
type Builder b = F ((,) b)
putB :: b -> Builder b ()
putB x = liftF (x, ())
bToList :: Builder b a -> [b]
bToList x = build $ \cons nil -> runF x (const nil) (uncurry cons)
main :: IO ()
main = print $ take 10 $ bToList $ forever (putB "a")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.