Possible bug with GADTs?

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Wed Aug 18 00:15:21 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/17/2010 03:22 PM, Ben Moseley wrote:
> {-# LANGUAGE GADTs #-}
> module Foo where
>
> data TemplateValue t where
>   TemplateList :: [x] -> TemplateValue [x]
>
> instance (Eq a) => Eq (TemplateValue a) where
>   (==) (TemplateList b) (TemplateList c) = (==) b c  -- here we have a
== [x]
>
>     Could not deduce (Eq x) from the context (a ~ [x1])
>
> It looks as though it has decided to use the (instance Eq x => Eq [x])
instance, and hence is searching for Eq x (which can't be deduced)
rather than using the (Eq a / Eq [x]) directly.  So, I guess that's an
interesting question why that happens...

Hm... isn't that a case of overlapping and/or incoherent instances?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxrXlgACgkQIn7hlCsL25USIQCfZ2cZXlZJZxVLI/m4pWkfA4+f
18EAnjIsecXNpJNbYUyfIPs7uTgoNi5M
=8tG5
-----END PGP SIGNATURE-----



More information about the Glasgow-haskell-users mailing list