[Haskell-cafe] OverlappingInstances-extension-like for type families
adam vogt
vogt.adam at gmail.com
Tue Jul 22 03:02:53 UTC 2014
Hi Leza,
You can make a closed type family (not associated with the class as you have):
type family ComplexSignalType e where
ComplexSignalType [C e] = [C e]
ComplexSignalType [e] = [C e]
But then you pretty much have to define all instances in the same
module. 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.
Regards,
Adam
On Mon, Jul 21, 2014 at 5:29 PM, Leza Morais Lutonda
<leza.ml at fecrd.cujae.edu.cu> wrote:
>
> Hello haskell-café,
>
> I just started working with type families, and come with some difficulties.
> Now I have a class:
>
> class (...) ⇒ Complexable s where
> type ComplexSignalType s
> ...
>
> Is there a possibility to have this two instances (in any way)?
>
> instance (RealFloat e) ⇒ Complexable [e] where
> type ComplexSignalType [e] = [ℂ e]
>
> instance (RealFloat e) ⇒ Complexable [ℂ e] where
> type ComplexSignalType [ℂ e] = [ℂ e]
>
>
> Thanks.
> --
> Leza Morais Lutonda, Lemol-C
> http://lemol.github.io
>
>
>
> 50 Aniversario de la Cujae. Inaugurada por Fidel el 2 de diciembre de 1964
> http://cujae.edu.cu
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list