Note that I created a PR for opaleye[1] giving it a cursor interface. With it I can write a Producer which doesn't need to fork a thread and push all rows through a MVar.
Bas [1] https://github.com/tomjaguarpaw/haskell-opaleye/pull/314 On 31 July 2017 at 10:36, Oliver Charles <ol...@ocharles.org.uk> wrote: > Depending on how you do that streaming, that might not be a disadvantage - > "single row mode" streaming requires all rows are processed before another > query is issued. On my library I use MonadResource to hook into stream > destruction and make sure any remaining rows are fetched. Not great, but > workable > > On Mon, 31 Jul 2017, 2:05 am Gabriel Gonzalez, <gabriel...@gmail.com> > wrote: > >> Note that you can turn the type of `fold` into a `Turtle.Shell` >> >> The type of `postgresql-simple`'s `fold` forces you to consume the stream >> exactly once, whereas `Producer`s, `ListT`s, and similar types let you >> traverse the stream or any element multiple times >> >> `Turtle.Shell` also has the advantage that it has built-in support for >> `Managed`, however, it has the major disadvantage that you have to consume >> the stream in its entirety, unlike `Producer`/`ListT` which let you >> partially consume a stream >> >> On Sun, Jul 30, 2017 at 12:50 PM, Tom Ellis < >> tom-lists-haskell-pipes-2...@jaguarpaw.co.uk> wrote: >> >>> Interesting. I've been wondering what we can do about the type of >>> `fold`. >>> Are there any strange consequences to generalising to `MonadIO`? For >>> example, what happens if we try to use this with `ListT IO`? I presume >>> it >>> behaves in a not very useful way. >>> >>> On Sun, Jul 30, 2017 at 06:42:16PM +0000, Oliver Charles wrote: >>> > It's necessary because the type of `fold` given in `postgresql-simple` >>> is >>> > fairly useless. It can't be massaged into the necessary shape of a free >>> > monad, so the best we can do is recover the steps by repeatedly pushing >>> > into an MVar and blocking. In my streaming-postgresql-simple library I >>> > write the fold's my self (using libpq) to avoid needing to introduce >>> > concurrency. >>> > >>> > On Sun, Jul 30, 2017 at 5:42 PM Tom Ellis < >>> > tom-lists-haskell-pipes-2...@jaguarpaw.co.uk> wrote: >>> > >>> > > On Sat, Jul 29, 2017 at 11:54:33PM +0200, Bas van Dijk wrote: >>> > > > I just started playing with pipes and I really like it so far. For >>> my >>> > > first >>> > > > project I would like to create a Producer for opaleye query >>> results. I >>> > > came >>> > > > up with the following: >>> > > > >>> > > > >>> > > https://github.com/basvandijk/pipes-opaleye/blob/master/src/ >>> Pipes/Opaleye/RunQuery.hs >>> > > > >>> > > > Is that the correct way of doing it? What can be improved? >>> > > >>> > > I'm curious about all the MVar business. Is this a typical thing to >>> do in >>> > > the pipes world? I thought there would be a more pure approach. >>> >>> -- >>> 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-pipes+unsubscr...@googlegroups.com. >>> To post to this group, send email to haskell-pipes@googlegroups.com. >>> >> >> -- >> 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-pipes+unsubscr...@googlegroups.com. >> To post to this group, send email to haskell-pipes@googlegroups.com. >> > -- > 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-pipes+unsubscr...@googlegroups.com. > To post to this group, send email to haskell-pipes@googlegroups.com. > -- 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-pipes+unsubscr...@googlegroups.com. To post to this group, send email to haskell-pipes@googlegroups.com.