[Haskell-beginners] Creating arrays in Haskell

Michal Kawalec michal
Wed Oct 2 10:45:58 UTC 2013


Excerpts from Karol Samborski's message of 2013-10-02 11:43:14 +0100:
> This is because ghci doesn't know which instance of IArray to use. If you
> look at type signature of function 'array' you'll see that it returns some
> type 'a i e' where 'a e' is an instance of IArray class. So what you must
> do is simply tell it what 'a i e' you want. Try this:
> 
> array (1,100) [(i, i*i) | i <- [1..100]] :: CArray Int Int

Thank you for that explanation, it worked.

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



More information about the Beginners mailing list