[Haskell-cafe] Problems with type family in a class

Leza Morais Lutonda leza.ml at fecrd.cujae.edu.cu
Mon Jul 21 06:16:46 UTC 2014


On 20/07/14 09:57, Niklas Haas wrote:
> Hmm, to be honest I'm not sure if this is effectively any different from
> what you had in your original example.
>
> Does this work as expected w.r.t type inferencing and instance selection?
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Yes, it works as expected, e.g, now I have instances of 
FourierTrasformable for List [Double] and for HMatrix.Vector Double, and 
the following works well:

> fft (toComplex [1,2,3,4 :: Double])
[10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)]
> fft (toComplex $ vector [1,2,3,4])
fromList [10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)]


I think (if I understand well) this is because the constraints 
(RealSignalType (ComplexSignalType s) ~ s) in the Complexable class 
definition and (csx ~ ComplexSignalType s, ComplexSignal csx) in the fft 
definition makes a one-by-one dependency between s and csx.

-- 
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