
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

On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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

Thanks. That makes sense.Grant
From: michael@snoyman.com Date: Mon, 5 Mar 2012 16:56:11 +0200 Subject: Re: [Haskell-cafe] Conduit Sink fork To: thelff@hotmail.com CC: haskell-cafe@haskell.org
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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

Thanks. That makes sense.Grant
From: michael@snoyman.com Date: Mon, 5 Mar 2012 16:56:11 +0200 Subject: Re: [Haskell-cafe] Conduit Sink fork To: thelff@hotmail.com CC: haskell-cafe@haskell.org
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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

Thanks. That makes sense.Grant
From: michael@snoyman.com Date: Mon, 5 Mar 2012 16:56:11 +0200 Subject: Re: [Haskell-cafe] Conduit Sink fork To: thelff@hotmail.com CC: haskell-cafe@haskell.org
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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

Thanks. That makes sense.Grant
From: michael@snoyman.com Date: Mon, 5 Mar 2012 16:56:11 +0200 Subject: Re: [Haskell-cafe] Conduit Sink fork To: thelff@hotmail.com CC: haskell-cafe@haskell.org
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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

Sorry for the repeat postings. My machine freaked out
From: michael@snoyman.com Date: Mon, 5 Mar 2012 16:56:11 +0200 Subject: Re: [Haskell-cafe] Conduit Sink fork To: thelff@hotmail.com CC: haskell-cafe@haskell.org
On Mon, Mar 5, 2012 at 1:54 AM, t helfferich
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@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
participants (2)
-
Michael Snoyman
-
t helfferich