RE: can't derive Monad

2003-07-30 Thread Simon Peyton-Jones
| 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

RE: can't derive Monad

2003-07-29 Thread Simon Peyton-Jones
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

Re: can't derive Monad

2003-07-29 Thread Dean Herington
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