It may not be a bug, because you do get an error, but it's certainly an 
infelicity because the error comes out much too late.   I'll Trac this and fix 
in due course.  Thanks for raising it.

Simon

| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dougal
| Stanton
| Sent: 09 August 2007 16:57
| To: haskell-cafe
| Subject: [Haskell-cafe] Derivation of Eq given Ord
|
| Is there a reason why automatic derivation of Ord without Eq doesn't
| do "the sensible thing" and just derive Eq anyway?
|
| > newtype Id a = Id { a :: String }
| >                    deriving (Read, Show, Eq, Ord)
| > newtype Ego a = Ego { b :: String }
| >                    deriving (Read, Show, Ord)
|
| Both will type check, but if you try any (in)equality operators on the
| second they'll be spat back at you.
|
| > *Main> let e1 = Ego ""
| > *Main> let e2 = Ego ""
| > *Main> e1 < e2
| >
| > <interactive>:1:0:
| >     No instance for (Eq (Ego a))
| >       arising from use of `<' at <interactive>:1:0-6
| >     Possible fix: add an instance declaration for (Eq (Ego a))
| >     In the expression: e1 < e2
| >     In the definition of `it': it = e1 < e2
|
| It doesn't seem *much* of a hardship, but it wasn't what I expected.
| I'm not used to GHC accepting input and silently dropping stuff it
| doesn't like...
|
| Cheers,
|
| D.
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to