How do you extract a value out of the Shell monad?
I would like to sequence a list of commands à la bash's &&
, but I would also like to extract the final ExitCode
value.
Say I have the following code:
import Turtle
type Commands = [Shell ExitCode]
run :: (MonadIO io) => Commands -> io ExitCode
run cs = whatIsThisFunction $ Prelude.foldl (.&&.) (return ExitSuccess) cs
whatIsThisFunction :: (MonadIO io) => Shell a -> io a
whatIsThisFunction = undefined
I tried to see if I could implement this with Control.Foldl, but did not find a solution.
Any ideas?
More generally, why doesn't Turtle provide a function with such signature:
sh' :: MonadIO io => Shell a -> io a