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

Leza Morais Lutonda leza.ml at fecrd.cujae.edu.cu
Thu Jul 17 02:32:27 UTC 2014


Hi,

Consider the following type classes:

class (Signal sx) => Complexable sx where
type ComplexSignalType
....

class (Complexable sx) => FourierTransformable sx where
fft :: (cx ~ ComplexSignalType sx) => cx -> cx
....

and an instance:

instance (RealFloat e) => Complexable [e] where
type ComplexSignalType = [Complex e]

instance (RealFloat e) => FourierTransformable [e] where
fft = ...

Why this example will give errors:

*DSP.Signals.Core Prelude Data.Complex> :t ax
ax :: [Complex Double]
*DSP.Signals.Core Prelude Data.Complex> fft ax

<interactive>:90:1:
No instance for (FourierTransformable s0 [Complex Double])
arising from a use of ‘fft’
The type variable ‘s0’ is ambiguous
Note: there is a potential instance available:
instance [overlap ok] (RealFloat e, Math.FFT.Base.FFTWReal e) =>
FourierTransformable [e] [Complex e]
-- Defined at src/DSP/Signals/Instances/List.hs:40:10
In the expression: fft ax
In an equation for ‘it’: it = fft ax


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