[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: [Haskell-cafe] servant streaming question
From: Zoran =?utf-8?Q?Bo=C5=A1njak?= <zoran.bosnjak () via ! si>
Date: 2023-06-30 18:00:03
Message-ID: 1583064132.3146.1688148003211.JavaMail.zimbra () via ! si
[Download RAW message or body]
Hi all,
I would like to reuse some streaming functions from the turtle package in the context \
of the servant streaming handler.
Relevant references:
https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Shell.html
https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Prelude.html
https://hackage.haskell.org/package/servant-0.20/docs/Servant-Types-SourceT.html
As a simple example:
Turtle.Prelude.ls function represents stream of FilePaths (directory listing of some \
path) ls :: FilePath -> Shell FilePath
Servant streaming is based around SourceT IO a, for example:
type ListFiles = "ls" :> StreamGet NewlineFraming PlainText (SourceT IO FilePath)
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:
shellToSource :: forall a. Shell a -> SourceIO a
shellToSource = ??
... such that I could reuse the 'ls' and write a streaming servant handler like this:
listFilesHandler :: Handler (SourceIO FilePath)
listFilesHandler = pure $ shellToSource $ Turtle.Prelude.ls "somePath"
Appreciate any suggestion.
regards,
Zoran
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic