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

Leza Morais Lutonda leza.ml at fecrd.cujae.edu.cu
Tue Jul 22 04:40:14 UTC 2014

On 21/07/14 23:02, adam vogt wrote:
> If you instead use functional dependencies (FDs):
> class Complexable s cs | s -> cs
> instance Complexable [e] [C e]
> instance Complexable [C e] [C e]
> you can put these instances in separate modules. But the disadvantage
> is that you have to deal with more type variables.

Hi Adam,

Actually, the Complexable class has a superclass, and the definition has 
a constraint like this:

class (Signal s,
        ComplexSignal (ComplexSignalType s)) => Complexable s where
        type ComplexSignalType s

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)

Leza Morais Lutonda, Lemol-C

50 Aniversario de la Cujae. Inaugurada por Fidel el 2 de diciembre de 1964  http://cujae.edu.cu

More information about the Haskell-Cafe mailing list