[Haskell-beginners] Exercise of "Programming with Arrows"

Kim-Ee Yeoh ky3 at atamo.com
Mon Oct 14 15:33:02 UTC 2013


On Tue, Oct 8, 2013 at 4:08 AM, Thiago Negri <evohunz at gmail.com> wrote:
> I agree with "no-op assembly line", but when I'm using `first` on a
processor, I want to process the first stream *only*. The second stream
should remain as it was not touched, so future processors will receive the
same sequence from the second stream.

We are in violent agreement!

> I mean, I think I need to guarantee that this definition holds:
>
> `g *** f` is the same as `first g >>> swap >>> first f >>> swap`

Excellent! Let's turn to laws and definitions to be _precise_ in what we're
saying.

> If my implementation of `first` uses a real no-op assembly line for `c`
(i.e., `arr id`), then I would lose the stream.

To that end, consider this easy problem: using

(1) the arrow laws that you know off the top of your head, and
(2) the above definition of (***)

can you show that g *** (arr id) = first g?

Because arr id, as you noted, is a no-op.

Do you see what's going on?


-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131014/02f1efcf/attachment-0001.html>


More information about the Beginners mailing list