From labra@lsi.uniovi.es Thu Feb 18 07:17:58 1988 Date: Thu, 18 Feb 1988 08:17:58 +0100 From: Jose Emilio Labra Gayo labra@lsi.uniovi.es Subject: Disjoint type classes
I have a large program where I would like to include disjoint type classes
into a new type class.

My problem can be reduced to the following example (taken from [1]):

> class Num a => Dividable a
>   where dividedBy :: a -> a -> a

> instance Fractional a => Dividable a where
> dividedBy = (/)

> instance Integral a => Dividable a where
>   dividedBy = div

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

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

[1] K. Glynn, M. Sulzmann,  P.J. Stuckey
    Type Classes and Constraint Handling Rules
    http://www.cs.mu.oz.au/tr_submit/test/cover_db/mu_TR_2000_7.html

Best regards, Jose Labra





From labra@lsi.uniovi.es Thu Feb 18 07:17:58 1988 From: labra@lsi.uniovi.es (Jose Emilio Labra Gayo) Date: Thu, 18 Feb 1988 08:17:58 +0100 Subject: Disjoint type classes Message-ID: <001601b205b3$20bd81c0$5d1f239c@ccu.uniovi.es> I have a large program where I would like to include disjoint type classes into a new type class. My problem can be reduced to the following example (taken from [1]): > class Num a => Dividable a > where dividedBy :: a -> a -> a > instance Fractional a => Dividable a where > dividedBy = (/) > instance Integral a => Dividable a where > dividedBy = div Which doesn't work because Haskell doesn't detect that "Integral" and "Fractional" are disjoint. Is there a way to implement these type classes with current Haskell implementations? [1] K. Glynn, M. Sulzmann, P.J. Stuckey Type Classes and Constraint Handling Rules http://www.cs.mu.oz.au/tr_submit/test/cover_db/mu_TR_2000_7.html Best regards, Jose Labra From labra@lsi.uniovi.es Thu Feb 18 07:17:58 1988 From: labra@lsi.uniovi.es (Jose Emilio Labra Gayo) Date: Thu, 18 Feb 1988 08:17:58 +0100 Subject: Disjoint type classes Message-ID: <001601b205b3$20bd81c0$5d1f239c@ccu.uniovi.es> I have a large program where I would like to include disjoint type classes into a new type class. My problem can be reduced to the following example (taken from [1]): > class Num a => Dividable a > where dividedBy :: a -> a -> a > instance Fractional a => Dividable a where > dividedBy = (/) > instance Integral a => Dividable a where > dividedBy = div Which doesn't work because Haskell doesn't detect that "Integral" and "Fractional" are disjoint. Is there a way to implement these type classes with current Haskell implementations? [1] K. Glynn, M. Sulzmann, P.J. Stuckey Type Classes and Constraint Handling Rules http://www.cs.mu.oz.au/tr_submit/test/cover_db/mu_TR_2000_7.html Best regards, Jose Labra From labra@lsi.uniovi.es Thu Feb 18 07:17:58 1988 From: labra@lsi.uniovi.es (Jose Emilio Labra Gayo) Date: Thu, 18 Feb 1988 08:17:58 +0100 Subject: Disjoint type classes Message-ID: <001601b205b3$20bd81c0$5d1f239c@ccu.uniovi.es> I have a large program where I would like to include disjoint type classes into a new type class. My problem can be reduced to the following example (taken from [1]): > class Num a => Dividable a > where dividedBy :: a -> a -> a > instance Fractional a => Dividable a where > dividedBy = (/) > instance Integral a => Dividable a where > dividedBy = div Which doesn't work because Haskell doesn't detect that "Integral" and "Fractional" are disjoint. Is there a way to implement these type classes with current Haskell implementations? [1] K. Glynn, M. Sulzmann, P.J. Stuckey Type Classes and Constraint Handling Rules http://www.cs.mu.oz.au/tr_submit/test/cover_db/mu_TR_2000_7.html Best regards, Jose Labra