[Haskell-cafe] Is ([] -> []) an arrow?

Jeff Polakow jeff.polakow at db.com
Wed Mar 21 15:36:16 EDT 2007


Hello,

> In John Hughes's "Programming With Arrows"
> (http://www.cs.chalmers.se/~rjmh/afp-arrows.pdf), he discusses a
> "stream function" type
> newtype SF a b = SF {runSF :: [a] -> [b]}
> and gives
> instance Arrow SF where ....
> He gives some examples using this, and everything seems to go just fine.
> 
I believe Hughes also states that it isn't really an arrow.

> But in Ross Patterson's "Arrows and Computation"
> (http://www.soi.city.ac.uk/~ross/papers/fop.html), he says that
> newtype ListMap i o = LM ([i] -> [o])
> is ALMOST an arrow.
> 
> Now, I've heard (but never verified) that IO fails to satisfy some
> monad laws, yet here we are, using it as a monad. Is a similar kind of
> thing going on here? Has anyone hit any snags in using this instance?
> 
It really isn't an arrow (hint to see why: nothing forces the length of 
the input list to match that of the output list) and thus the arrow laws 
are not sound for this type. This will be a problem for you if your 
compiler attempts to optimize arrow expressions using the arrow laws (I 
think, but I'm not sure, that GHC tries to do this when using arrow 
notation).

-Jeff

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070321/1bae9cfd/attachment.htm


More information about the Haskell-Cafe mailing list