Overlapping, undecidable, incoherent -- or worse?

Alex Ferguson abf at cs.ucc.ie
Thu May 20 01:52:43 EDT 2004

The following rings a faint bell from somewhere, but if there's a standard
workaround I can't recall or lay my hand on it currently:  
> class PO a where
>    (|=) :: a -> a -> Bool
> class Num a => SemiRing a
> class SemiRing a => CSemiRing a
> instance (Bounded a, Enum a, SemiRing a) => PO a where
>    a |= b
>       = or [ a + c == b | c <- boundedEnumFrom minBound ]
> instance CSemiRing a => PO a where
>    a |= b = a + b == b

The above is in any event requires the "-fallow-undecidable-instances"
flag, due to the format of the instance clauses, and they're worse than
merely "overlapping" due to the identical heads.  But I'm not quite
clear why "incoherent" doesn't help here:  isn't the gist of that to
allow the second to override the first, where they conflict?  Is there
otherwise a means to have it behave in such a way?

(I can hack around this by removing the distinction betweem the two
classes and encoding it as run-time property (which may get compiled out
statically anyway, and I suspect what I actually want are hierarchical
defaults rather than instances, but that's more like fodder for another


More information about the Glasgow-haskell-users mailing list