Added convenience runner for things that implement Show

This commit is contained in:
Gabriel Gonzalez 2015-01-18 20:57:33 -08:00
parent 5e2d77f65f
commit 91d0ad620f

View file

@ -58,6 +58,7 @@
module Turtle.Shell (
Shell(..)
, feed
, shell
, sh
-- * Embeddings
@ -85,8 +86,14 @@ feed :: Shell a -> Fold a b -> IO b
feed s f = feedIO s (Foldl.generalize f)
-- | Run a `Shell` to completion, discarding any unused values
sh :: Shell a -> IO ()
sh s = feed s (pure ())
shell :: Shell a -> IO ()
shell s = feed s (pure ())
-- | Run a `Shell` to completion, `print`ing any unused values
sh :: Show a => Shell a -> IO ()
sh s = shell (do
x <- s
liftIO (print x) )
instance Functor Shell where
fmap f s = Shell (\(FoldM step begin done) ->