Hi,

On Fri, 11 Feb 2005 12:02:56 +0100, Thomas Jäger <[EMAIL PROTECTED]> wrote:
>
> iii) As a side effects of how n+k patterns work, each instance of the
> Num class must also be an instance of Eq, which of course doesn't make
> sense for all numeric types.

Well this is not entirely true.  I don't think 'n+k' patterns need
equality, but they need ordering
f (n + k) = e
is like:
f x | x > k = let n = x - k in e

Literal patterns need equality:
f 2 = e
is like:
f x | x == 2 = e

These do not force the 'Num' class to be a superclass of 'Ord' or
'Eq'.  If 'Num' was not a superclass of 'Eq', whenver you used a
literal pattern there would be an extra constraint that there should
be equality on the corresponding type. For example:
f 2 = "Hello"
would get the type:
f :: (Eq a, Num a) => a -> String

Hope this helps
-Iavor
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to