
20 Jul
2006
20 Jul
'06
1:38 p.m.
Hi,
The short answer: use runST (long expression) rather than runST $ long expression
when it comes to higher-ranked functions such as runST.
I suppose the same holds for runSTUArray, right? But this still gives me that same error, about being less polymorphic than expected. (+=) x y = let updateX i = do xi <- readArray x i writeArray x i (xi + y!i) in sequence_ . map updateX $ indices x sumArrays [] = error "Can't apply sumArrays to an empty list" sumArrays (x:xs) = runSTUArray result where result = do x0 <- thaw x mapM_ (x0 +=) xs x0 -- Chad Scherrer "Time flies like an arrow; fruit flies like a banana" -- Groucho Marx