
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. 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? Thanks, Chad

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.
participants (2)
-
Chad Scherrer
-
Jeff Polakow