Singular Type Constructor
Ashley Yakeley
ashley@semantic.org
Sun, 12 Aug 2001 18:39:24 -0700
At 2001-08-12 11:26, Levent Erkok wrote:
>How about using overlapping instances? Add:
>
> instance Eq a where
> _ == _ = True
>
>to your program: if there isn't a ``better'' instance, it'll use this one.
>Such an instance declaration is inherently dangerous to have around, but
>might help your particular situation.
How do Hugs and GHC calculate "better" instances in this case?
I make a distinction between "appears to overlap" and "actually
overlaps": the first is what the compilers detect: I only switch off this
checking if I have instances that "appear to" overlap but don't
"actually" overlap e.g.:
--
instance MyClass Bool
instance (Num a) => MyClass a
--
...which don't "actually" overlap provided I don't have "instance Num
Bool" anywhere.
Patching GHC so that it detects instances that "actually" overlap instead
of "appear to" overlap is left as an exercise for the reader...
--
Ashley Yakeley, Seattle WA