[Haskell-beginners] Creating arrays in Haskell

Michal Kawalec michal
Wed Oct 2 10:26:36 UTC 2013


Excerpts from Karol Samborski's message of 2013-10-02 11:11:15 +0100:
> I think you should just add type signature to the [1..100], like this:
> array (1,100) [(i, i*i) | i <- ([1..100]::[Int])]

Thank you, it seems that it worked, but with my limited knowledge of
Haskell I stumbled onto another problem:

Prelude Data.List Math.FFT Data.Array.CArray Data.Array.Base> array (1,100) [(i, i*i) | i <- [1..100]::[Int]]

<interactive>:74:1:
    No instance for (IArray a0 Int) arising from a use of `array'
    The type variable `a0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance Foreign.Storable.Storable e => IArray CArray e
        -- Defined in `Data.Array.CArray.Base'
      instance IArray Array e -- Defined in `Data.Array.Base'
      instance IArray UArray Int -- Defined in `Data.Array.Base'
    Possible fix: add an instance declaration for (IArray a0 Int)
    In the expression:
      array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]
    In an equation for `it':
        it = array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]


-- 
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/cd251b5c/attachment.sig>



More information about the Beginners mailing list