[Haskell-cafe] Yet another Conduit question

Michael Snoyman michael at snoyman.com
Mon Feb 4 10:25:11 CET 2013


I think this is probably the right approach. However, there's something
important to point out: flushing based on timing issues must be handled
*outside* of the conduit functionality, since by design conduit will not
allow you to (for example) run `await` for up to a certain amount of time.
You'll probably need to do this outside of your conduit chain, in the
initial Source. It might look something like this:

yourSource = do
    mx <- timeout somePeriod myAction
    yield $ maybe Flush Chunk mx
    yourSource


On Sun, Feb 3, 2013 at 5:06 PM, Felipe Almeida Lessa <felipe.lessa at gmail.com
> wrote:

> I guess you could use the Flush datatype [1] depending on how your
> data is generated.
>
> Cheers,
>
> [1]
> http://hackage.haskell.org/packages/archive/conduit/0.5.4.1/doc/html/Data-Conduit.html#t:Flush
>
> On Fri, Feb 1, 2013 at 6:28 AM, Simon Marechal <simon at banquise.net> wrote:
> > On 01/02/2013 08:21, Michael Snoyman wrote:
> >> So you're saying you want to keep the same grouping that you had
> >> originally? Or do you want to batch up a certain number of results?
> >> There are lots of ways of approaching this problem, and the types don't
> >> imply nearly enough to determine what you're hoping to achieve here.
> >
> > Sorry for not being clear. I would like to group them "as much as
> > possible", that is up to a certain limit, and also within a "time
> > threshold". I believe that the conduit code will be called only when
> > something happens in the conduit, so an actual timer would be useless
> > (unless I handle this at the source perhaps, and propagate "ticks").
> >
> > That is why in my first message I talked about stacking things into the
> > list until the conduit has no more input available, or a maximum size is
> > reached, but was not sure this even made sense.
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> --
> Felipe.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130204/65504346/attachment.htm>


More information about the Haskell-Cafe mailing list