<div dir="ltr">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<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 30 Jun 2023 at 21:00, Zoran Bošnjak <<a href="mailto:zoran.bosnjak@via.si">zoran.bosnjak@via.si</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
I would like to reuse some streaming functions from the turtle package in the context of the servant streaming handler.<br>
<br>
Relevant references:<br>
<a href="https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Shell.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Shell.html</a><br>
<a href="https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Prelude.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Prelude.html</a><br>
<a href="https://hackage.haskell.org/package/servant-0.20/docs/Servant-Types-SourceT.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/servant-0.20/docs/Servant-Types-SourceT.html</a><br>
<br>
As a simple example:<br>
<br>
<a href="http://Turtle.Prelude.ls" rel="noreferrer" target="_blank">Turtle.Prelude.ls</a> function represents stream of FilePaths (directory listing of some path)<br>
ls :: FilePath -> Shell FilePath<br>
<br>
Servant streaming is based around SourceT IO a, for example:<br>
type ListFiles = "ls" :> StreamGet NewlineFraming PlainText (SourceT IO FilePath)<br>
<br>
The problem is that the streaming (Shell a) is not exactly the same as servant's (SourceT IO a). But as far as I understand, they both represent "stream of values of type 'a'". My question is: Is a generic conversion function possible? Something like:<br>
<br>
shellToSource :: forall a. Shell a -> SourceIO a<br>
shellToSource = ??<br>
<br>
... such that I could reuse the 'ls' and write a streaming servant handler like this:<br>
<br>
listFilesHandler :: Handler (SourceIO FilePath)<br>
listFilesHandler = pure $ shellToSource $ <a href="http://Turtle.Prelude.ls" rel="noreferrer" target="_blank">Turtle.Prelude.ls</a> "somePath"<br>
<br>
Appreciate any suggestion.<br>
<br>
regards,<br>
Zoran<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>