Re: map and fmap

2006-08-20 Thread Jeffrey Yasskin

On 8/20/06, John Hughes <[EMAIL PROTECTED]> wrote:


From: "Jon Fairbairn" <[EMAIL PROTECTED]>

> 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
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: map and fmap

2006-08-20 Thread Aaron Denney
On 2006-08-20, John Hughes <[EMAIL PROTECTED]> wrote:
>
> From: "Jon Fairbairn" <[EMAIL PROTECTED]>
>
>> 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.

Solely due to the compiler no longer seeing that list is the only
intermediate type allowed.  But you have to admit this code is a bit
forced.  People won't be combining things quite this way, and will be
passing in values rather than bare returns.

> In any case, I'm dubious about this as a criterion. I would guess that the 
> majority if compiler runs for beginners (and perhaps for the rest of us 
> too!) end in a type error, not a successful compilation, so arguably the 
> quality of error messages when a type-check fails is more important than 
> which programs compile.

Right, like I said, we need to work on better error messages.

-- 
Aaron Denney
-><-

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: map and fmap

2006-08-20 Thread John Hughes


From: "Jon Fairbairn" <[EMAIL PROTECTED]>


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.


In any case, I'm dubious about this as a criterion. I would guess that the 
majority if compiler runs for beginners (and perhaps for the rest of us 
too!) end in a type error, not a successful compilation, so arguably the 
quality of error messages when a type-check fails is more important than 
which programs compile.


John



___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: map and fmap

2006-08-20 Thread John Hughes


From: "Jon Fairbairn" <[EMAIL PROTECTED]>


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.


In any case, I'm dubious about this as a criterion. I would guess that the 
majority if compiler runs for beginners (and perhaps for the rest of us 
too!) end in a type error, not a successful compilation, so arguably the 
quality of error messages when a type-check fails is more important than 
which programs compile.


John



___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: map and fmap

2006-08-20 Thread John Hughes


From: "Jon Fairbairn" <[EMAIL PROTECTED]>


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.


In any case, I'm dubious about this as a criterion. I would guess that the 
majority if compiler runs for beginners (and perhaps for the rest of us 
too!) end in a type error, not a successful compilation, so arguably the 
quality of error messages when a type-check fails is more important than 
which programs compile.


John



___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime