Consider (inshell "echo A line of text." empty)
has type Shell Line
.
Question: How can one convert a value of this type to Text
?
Consider (inshell "echo A line of text." empty)
has type Shell Line
.
Question: How can one convert a value of this type to Text
?
You can't. See the definition of
Shell
*.You can only get
IO
thingies out of it. However you can probably get anIO Text
, and since you're doing shell stuff I suspect you have anIO
monad context hanging around.FoldM
is defined as*So if we can construct a
FoldM IO Line Text
then we can get what we need, I suspect. Here's a guess (not typechecked, and this is getting kind of complicated so I'm probably making mistakes).This can probably be considerably simplified by using the combinators in
Control.Foldl
, but I'll leave that as an exercise.(*) In case you're not familiar, the first
forall
indicates a rank-2 type and the second one indicates an existential type.