Chris Kuklewicz wrote:
Brian Hulley wrote:
Ben Rudiak-Gould wrote:
... but no more confusing than the fact that [f x | x <- xs] is
not the same as (map f xs).

Can you explain why? On page 258 of Paul Hudak's book "The Haskell
School of Expression" he states that do x<- xs; return (f x) is
equivalent to [f x | x <- xs] "which is clearly just map f xs"

I can't find anything wrong with the example in the book but perhaps
I've missed something?

He may mean that if you *redefine* the operator Prelude.((:)) then the
desugaring and other steps may end up binding the old or the new (:) and no
longer be identical.  This is touched on in

http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/syntax-extns.html#rebindable-syntax

In particular, if you redefine Monad, then [ f x | x<-xs ] and do {x<-xs; return
x} may no longer mean the same thing.

Right, but the original question is whether or not [f x | x <- xs] is the same as map f xs. My book's been out for six years and no one has mentioned this issue, so if it's a problem I'd like to know why so that I can add it to my "Errata" list!

Thanks,  -Paul
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to