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
IOthingies out of it. However you can probably get anIO Text, and since you're doing shell stuff I suspect you have anIOmonad context hanging around.FoldMis defined as*So if we can construct a
FoldM IO Line Textthen 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
forallindicates a rank-2 type and the second one indicates an existential type.