[Haskell-cafe] A type class puzzle

Jacques Carette carette at mcmaster.ca
Tue Oct 31 17:18:03 EST 2006


Greg Buchholz wrote:
>     I guess it just looks really strange to my eyes.  For example, "foo"
> and "bar" are legal, but "baz" isn't.  That's what I was thinking of the
> situation, but I guess the type classes iron out the differences. 
>   
>> foo :: Int -> Int -> Int -> Int
>> foo 0 = (+)
>>
>> bar :: Int -> Int -> Int -> Int
>> bar 1 x = succ
>>
>> baz :: Int -> Int -> Int -> Int
>> baz 0 = (+)
>> baz 1 x = succ
>>
>>     

This could be understood as a weakness in the de-sugaring of 
pattern-matching, because

bong :: Int -> Int -> Int -> Int
bong 0 = (+)
bong 1 = \x -> succ

is just fine.

Jacques



More information about the Haskell-Cafe mailing list