[Haskell-cafe] Problems with type families

Leza Morais Lutonda leza.ml at fecrd.cujae.edu.cu
Mon Jul 6 19:20:11 UTC 2015


Hi Silvio, thanks for the answer.

> What's the error message? Is a bit hard without that.

The error message is: (the source code is attached)

src/DSP/Sig.hs:41:25:
     Could not deduce (TFunOut t1 e ~ TFunOut t1 e0)
     from the context (SignalT t1 e,
                       SignalT t2 e,
                       TFunOut t2 e ~ TFunIn t1 e)
       bound by the instance declaration at src/DSP/Sig.hs:39:10-95
     NB: ‘TFunOut’ is a type function, and may not be injective
     The type variable ‘e0’ is ambiguous
     Expected type: TFunOut (ComposeT t1 t2) e
       Actual type: TFunOut t1 e0
     Relevant bindings include
       x :: TFunIn (ComposeT t1 t2) e (bound at src/DSP/Sig.hs:41:21)
       transform :: ComposeT t1 t2
                    -> TFunIn (ComposeT t1 t2) e -> TFunOut (ComposeT t1 
t2) e
         (bound at src/DSP/Sig.hs:41:9)
     In the expression:
       (transform (undefined :: t1) . transform (undefined :: t2)) x
     In an equation for ‘transform’:
         transform _ x
           = (transform (undefined :: t1) . transform (undefined :: t2)) x

src/DSP/Sig.hs:41:26:
     Could not deduce (TFunIn t1 e0 ~ TFunOut t2 e1)
     from the context (SignalT t1 e,
                       SignalT t2 e,
                       TFunOut t2 e ~ TFunIn t1 e)
       bound by the instance declaration at src/DSP/Sig.hs:39:10-95
     The type variables ‘e0’, ‘e1’ are ambiguous
     Expected type: TFunOut t2 e1 -> TFunOut t1 e0
       Actual type: TFunIn t1 e0 -> TFunOut t1 e0
     Relevant bindings include
       x :: TFunIn (ComposeT t1 t2) e (bound at src/DSP/Sig.hs:41:21)
       transform :: ComposeT t1 t2
                    -> TFunIn (ComposeT t1 t2) e -> TFunOut (ComposeT t1 
t2) e
         (bound at src/DSP/Sig.hs:41:9)
     In the first argument of ‘(.)’, namely
       ‘transform (undefined :: t1)’
     In the expression:
       transform (undefined :: t1) . transform (undefined :: t2)

src/DSP/Sig.hs:41:56:
     Could not deduce (TFunIn t2 e1 ~ TFunIn t2 e)
     from the context (SignalT t1 e,
                       SignalT t2 e,
                       TFunOut t2 e ~ TFunIn t1 e)
       bound by the instance declaration at src/DSP/Sig.hs:39:10-95
     NB: ‘TFunIn’ is a type function, and may not be injective
     The type variable ‘e1’ is ambiguous
     Expected type: TFunIn t2 e -> TFunOut t2 e1
       Actual type: TFunIn t2 e1 -> TFunOut t2 e1
     Relevant bindings include
       x :: TFunIn (ComposeT t1 t2) e (bound at src/DSP/Sig.hs:41:21)
       transform :: ComposeT t1 t2
                    -> TFunIn (ComposeT t1 t2) e -> TFunOut (ComposeT t1 
t2) e
         (bound at src/DSP/Sig.hs:41:9)
     In the second argument of ‘(.)’, namely
       ‘transform (undefined :: t2)’
     In the expression:
       transform (undefined :: t1) . transform (undefined :: t2)
Failed, modules loaded: none.

>
> The problem is probably that you have to explicitly state everything.
>
> Maybe
>
> TFunIn (ComposeT t1 t2) e ~ TFunOut (SignalT t2 e)
>
> The problem with typefamilies is that often things can not be used as
> you would expect unless you state things explicitly.
>
> It is because the instance declaration can not know that TFunIn is
> always the same. You could import two different ones from different
> modules and thus convert one type into another.
>
> closed typefamilies can sometimes help too.


-- 
Leza Morais Lutonda, Lemol-C
Electronic and Telecommunication Engineer
Software Development and Architecture Enthusiast
http://lemol.github.io



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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Sig.hs
Type: text/x-haskell
Size: 1031 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150706/945f20b9/attachment.hs>


More information about the Haskell-Cafe mailing list