| You'd get
|
| instance Eq [T] = Eq T
|
| which will make the type checker loop for sure.
|
| Actually not.
|
| swan(102)% cat Deriving.hs
| newtype N = N [N] deriving Eq
What it's doing is *first* trying the new newtype-deriving stuff,
failing (because recursive) and then trying
Just conservatism. Imagine
newtype T = MkT [T] deriving(Eq)
You'd get
instance Eq [T] = Eq T
which will make the type checker loop for sure. I'm not sure what a
safe approximation might be. But I'll put your example in a comment in
the source code as an example of a safe one
Simon Peyton-Jones wrote:
Just conservatism. Imagine
newtype T = MkT [T] deriving(Eq)
You'd get
instance Eq [T] = Eq T
which will make the type checker loop for sure.
Actually not.
swan(102)% cat Deriving.hs
newtype N = N [N] deriving Eq
n1 = N []
n2 = N []
n3 = N