Added convenience runner for things that implement Show
This commit is contained in:
parent
5e2d77f65f
commit
91d0ad620f
1 changed files with 9 additions and 2 deletions
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue