[Haskell-cafe] Conduit Sink fork
Michael Snoyman
michael at snoyman.com
Mon Mar 5 15:56:11 CET 2012
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich <thelff at hotmail.com> wrote:
> Hi!
> So, it turns out I have a need for a sink that forks input into two other
> sinks using the Conduit package. Here is what I came up
> with: https://gist.github.com/1975383
>
> Is this the right way to write it? Also, what left over value(s) should I
> return in the Done constructor?
>
> I appreciate any help you can give me.
>
> Thanks so much,
> Grant
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
It looks like the right approach to me. What to do with the leftover
values is a really good question, and I don't think there's really an
obvious answer. I can think of a few approaches:
* What you've done: never return leftover values.
* Always return the ll (or rr).
* Return whichever leftover value is Just, or if both are Just,
arbitrarily choosing one of them
Similarly, you could take different approaches to what to do when
processing terminates early:
* What you've done: continue pushing data until both Sinks return Done
* Terminate whenever the left (or right) Sink returns Done
* Terminate when *either* returns Done
Again, there's no right answer here, they all seem like valid approaches.
Michael
More information about the Haskell-Cafe
mailing list