[Haskell-cafe] Problems with type families
Leza Morais Lutonda
leza.ml at fecrd.cujae.edu.cu
Mon Jul 6 17:20:13 UTC 2015
Hi All!
Consider the following definitions:
type family TFunIn t e
type family TFunOut t e
data IdT
data ComposeT t1 t2
-- etc...
type instance TFunIn (ComposeT t1 t2) e = TFunIn t2 e
type instance TFunOut (ComposeT t1 t2) e = TFunOut t1 e
-- etc...
class SignalT t e
where
transform :: t -> TFunIn t e -> TFunOut t e
instance (SignalT t1 e, SignalT t2 e) => SignalT (ComposeT t1 t2) e
where
transform _ x = (transform (undefined :: t1) . transform (undefined :: t2)) x
Due to the `TFunIn` and `TFunOut` type families instances for [(ComposeT
t1 t2) e], the `transform` function for
[(ComposeT t1 t2) e] instance of SignalT should be inferred as:
transform :: t -> TFunIn (ComposeT t1 t2) e -> TFunOut (ComposeT t1 t2) e
<==> :: t -> TFunIn t2 e -> TFunOut t1 e
But I cannot figure out why it does not compile.
Any ideas?
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
More information about the Haskell-Cafe
mailing list