| ps: you successfully going through all the standard Haskell troubles
in
| this area :) seems that making FAQ about using ST monad will be a
| good idea :)
Indeed. If someone would like to start one, a good place for it would be
GHC's collaborative-documentation Wiki
http://haskell.org/
Chad Scherrer wrote:
> But why should this...
>
> >sumArrays [] = error "Can't apply sumArrays to an empty list"
> >sumArrays (x:xs) = runSTArray (result x)
> >where
> >result x = do x0 <- thaw x
> > mapM_ (x0 +=) xs
> > return x0
>
> work differently tha
Ok, I see now why the return is necessary. For now I'll switch to
boxed arrays until I get the rest of this down better.
But why should this...
sumArrays [] = error "Can't apply sumArrays to an empty list"
sumArrays (x:xs) = runSTArray (result x)
where
result x = do x0 <- thaw x