I have managed to convert in one direction like this:
```
sourceToShell :: forall a. SourceIO a -> Shell a
sourceToShell (S.SourceT act1) = Shell act2 where
act2 :: FoldShell a r -> IO r
act2 (FoldShell step begin done) = act1 (go begin) where
go x = \case
S.Stop -> done x
S.Error e -> fail e
S.Skip cont -> go x cont
S.Yield val cont -> step x val >>= flip go cont
S.Effect eff -> eff >>= go x
```
But in the other way (that is: shellToSource) I could not find any clean solution. I've got information from turtle's author that it's not possible directly by simple manupulation of data structures. It should however be possible by forking a new thread, write elements from Shell to some shared buffer and let StepT read from this buffer. But I have decided to re-implement some small set of turtle's functions (like 'ls') to produce SourceIO, instead of Shell, so this conversion is not needed any more.
Zoran
From: "Bryan Richter" <bryan@haskell.foundation>
To: "Zoran Bošnjak" <zoran.bosnjak@via.si>
Cc: "haskell-cafe" <haskell-cafe@haskell.org>
Sent: Monday, July 10, 2023 9:19:44 AM
Subject: Re: [Haskell-cafe] servant streaming question
In short, yes I think it should be possible. But messing with Shell / Fold always feels like doing a brain teaser rather than programming. If you figure it out, I would like to hear about it. :P