yet another very simple overlapping instance example

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Wed, 25 Jun 2003 13:09:28 +0100


> instance Op_plus MyInt MyInt where
> instance (Num a) => Op_plus a MyInt where
> instance (Num a) => Op_plus MyInt a where
[..]
> Overlapping instance declarations:
>    multi.hs:9: Op_plus a MyInt
>    multi.hs:12: Op_plus MyInt a
> Failed, modules loaded: none.

The GHC manual talks about this at:

http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/type-extensions.html#INSTANCE-DECLS

I think the issue is that GHC still requires that overlapping
instances either do not unify, or have an instantiation ordering.
Your 2nd and 3rd instances are unordered: 2 is an instance of 3, and 3
is an instance of 2.  GHC doesn't notice the first instance.

I observe that the docs above say "Yell if this restriction bites
you.", so I shall hand this over to the GHC developers to discuss
further...

--KW 8-)