[Haskell-beginners] Stymied by mutable arrays in the ST monad
Matthew Moppett
matthewmoppett at gmail.com
Fri May 25 18:50:57 CEST 2012
I've been trying to use mutable arrays in the ST monad, and wrote out a
little proof of concept function:
idST :: [Int] -> [Int]
idST xs = runST $ do
array <- newListArray (1, (length xs)) xs
return (getElems array)
-- where idSt should be equivalent to id.
And I get the error message:
Couldn't match type `[Int]' with `Int'
In the return type of a call of `getElems'
In the first argument of `return', namely `(getElems array)'
In a stmt of a 'do' block: return (getElems array)
Obviously I'm making a very simple mistake here, but I can't seem to spot
it. Can anyone offer some advice?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120526/e31d586b/attachment.htm>
More information about the Beginners
mailing list