
On 8/20/06, John Hughes
From: "Jon Fairbairn"
To reinforce what Aaron said, if a programme works now, it'll still work if map suddenly means fmap.
Well, this isn't quite true, is it? Here's an example:
class Foldable f where fold :: (a -> a -> a) -> a -> f a -> a
instance Foldable [] where fold = foldr
example = fold (+) 0 (map (+1) (return 2))
example has the value 3 (of course), but if you replace map by fmap then the code no longer compiles.
There's a proposal http://hackage.haskell.org/trac/haskell-prime/wiki/Defaulting that mentions extending defaulting to other typeclasses. That seems to fix this particular problem, but above you mentioned that this was "a whole new can of worms." Could you elaborate or point me to a discussion of the worms? Thanks, Jeffrey