[Haskell-beginners] Creating arrays in Haskell

Michal Kawalec michal
Wed Oct 2 09:51:52 UTC 2013


Hello,

I want to use the FFT library in Haskell and for that I need to create
an array. However, when I input 

    array (1,100) [(i, i*i) | i <- [1..100]]

in ghci, I get an error saying:

    No instance for (Enum e0)
      arising from the arithmetic sequence `1 .. 100'
    The type variable `e0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance Enum Double -- Defined in `GHC.Float'
      instance Enum Float -- Defined in `GHC.Float'
      instance Integral a => Enum (GHC.Real.Ratio a)
        -- Defined in `GHC.Real'
      ...plus 15 others
    In the expression: [1 .. 100]
    In a stmt of a list comprehension: i <- [1 .. 100]
    In the second argument of `array', namely
      `[(i, i * i) | i <- [1 .. 100]]'

Could you please tell me how to add the type signature?

-- 
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131002/fd3512aa/attachment-0001.sig>



More information about the Beginners mailing list