Don't understand the correct way to compose "meta" producers.

36 views
Skip to first unread message

Daniel Hill

unread,
Apr 14, 2017, 12:32:06 AM4/14/17
to Haskell Pipes
Hey guys,

the types of Pipes.Zlib/Gzip are in the form Producer -> Producer, if I was to implement such a library my first though would be to make them Pipes, so you could compose them as such ` producer >-> compress >-> consumer`.

instead i have to use the form `for producer (\x -> compress (yield x)) >-> consumer` which works correctly for my current project, but I'm left wondering why I have to perform such gymnastics to turn them in to pipes, something tells me that i need  to use ~> but even if I can get it to compile, I don't get any output.

So can anyone give me some insight to this, thanks

- Daniel

Gabriel Gonzalez

unread,
Apr 14, 2017, 12:44:56 PM4/14/17
to haskel...@googlegroups.com
There is no way to turn a `Producer -> Producer` into a `Pipe` in general.  Usually the point of writing a function of type `Producer -> Producer` is so that you can detect and handle the end of input.  If your `compress` function is doing something similar then something like `for producer (compress . yield)` might misbehave because it will treat each value yielded by the `producer` as having its own end of input.

--
You received this message because you are subscribed to the Google Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-pipe...@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages