[Haskell-cafe] OverlappingInstances-extension-like for type families

adam vogt vogt.adam at gmail.com
Tue Jul 22 18:02:08 UTC 2014


On Tue, Jul 22, 2014 at 12:40 AM, Leza Morais Lutonda
<leza.ml at fecrd.cujae.edu.cu> wrote:
> Trying to use functional dependencies, I end refactoring the Complexable
> class to:
>
> class (ComplexSignal csx rsx cel rel) ⇒ Complexable csx rsx cel rel | cel →
> csx, rel → rsx, rsx → csx
>
> But these instances still conflicting:
>
> instance (RealFloat e) ⇒ Complexable [ℂ e] [e] (ℂ e) e
> instance (RealFloat e) ⇒ Complexable [ℂ e] [ℂ e] (ℂ e) (ℂ e)

Hi Leza,

I believe those instances are accepted in ghc-7.6. In future ghcs, it
looks like there will be an extension that allows them again:
https://phabricator.haskell.org/D69

In the meantime you could add another parameter for the 'e':

class Complexable csx rsx cel rel e | cel → csx, rel → rsx, e rsx →
csx, csx -> e
instance (RealFloat e) ⇒ Complexable [C e] [e] (C e) e e
instance (RealFloat e) ⇒ Complexable [C e] [C e] (C e) (C e) e


Or you could keep the Complexable class as you had it, but write the
instances for particular 'e' like:

instance Complexable [C Double] [Double] (C Double) Double


Regards,
Adam


More information about the Haskell-Cafe mailing list