Disjoint type classes

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
5 Mar 2001 21:12:30 GMT

Thu, 18 Feb 1988 08:17:58 +0100, Jose Emilio Labra Gayo <labra@lsi.uniovi.es> pisze:

> Which doesn't work because Haskell doesn't detect that
> "Integral" and "Fractional" are disjoint.

And indeed there is no disjointness concept in the language.
Nothing prevents from making a type an instance of both.

> Is there a way to implement these type classes with current Haskell
> implementations?

I'm afraid not. In the standard way you must decide for each type
separately. At most you could use ghc with -fallow-overlapping-instances
-fallow-undecidable-instances, which would allow to define one of your
instances - the other would have to be defined for each type separately;
but these options are not nice.

 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
  ^^                      SYGNATURA ZASTĘPCZA