Ticket #1608 (closed bug: fixed)
Newtype deriving error messages coming out too late
| Reported by: | simonpj | Owned by: | simonpj |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.10 branch |
| Component: | Compiler (Type checker) | Version: | 6.6.1 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | drvfail012 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
Consider this
newtype Ego a = Ego a deriving (Ord) f :: Ord a => Ego a -> Ego a -> Bool f e1 e2 = e1 < e2
GHC 6.7 reports an error like this:
Could not deduce (Eq (Ego a)) from the context (Ord a)
arising from a use of `<' at Foo10.hs:6:10-16
In the expression: e1 < e2
In the definition of `f': f e1 e2 = e1 < e2
This error should have come when you gave the instance decl. The reason is that GHC's newtype deriving is generating an instance like
instance Eq (Ego a) => Ord (Ego a)
It would make more sense to report the missing instance for Eq right there, rather than abstracting over it.
Thanks to Dougal Stanton for pointing this out: http://www.haskell.org/pipermail/haskell-cafe/2007-August/030224.html
Change History
Note: See
TracTickets for help on using
tickets.
