GADT + Newtype deriving = Erroneous errors

Chris Kuklewicz haskell at list.mightyreason.com
Wed Mar 28 09:06:11 EDT 2007


Tomasz Zielonka wrote:
> On Mon, Mar 26, 2007 at 09:18:34PM -0700, Stefan O'Rear wrote:
>> stefan at stefans:/tmp$ cat A.lhs
>>> {-# OPTIONS_GHC -fglasgow-exts #-}
>>>
>>> data IsIntT x where IsIntT :: IsIntT Int
>>>
>>> class IsIntC a where isInt :: IsIntT a
>>> instance IsIntC Int where isInt = IsIntT
>>>
>>> newtype Foo = Foo Int deriving(IsIntC)
> 
> I think newtype deriving should be rejected in this case. Maybe this is
> the real problem here?
> 
> Best regards
> Tomek

On reflection, I agree.  The derived instance would have to be

> instance IsIntC Foo where 
>   isInt :: IsIntT Foo
>   isInt = isIntT

which cannot type check.  Only

> instance IsIntC Foo where
>   isInt :: IsIntT Foo
>   isInt = undefined

is possible.


More information about the Glasgow-haskell-users mailing list