[Haskell-cafe] problem using ST monad

Paul L ninegua at gmail.com
Sat Oct 25 23:55:33 EDT 2008


Tnaks for the clarification, please see my further questions below

On 10/25/08, Daniel Fischer <daniel.is.fischer at web.de> wrote:
>
> Sure, (g (flip readArray 0)) :: ST s Int, or, explicitly, forall s. ST s Int,
> there's nothing to restrict the s, so it's legitimate to pass it to runST.
..[snipped]..
> What would be a generic mapST, which type should it have?

I tried this type for mapST, it doesn't work:

  mapST :: (a -> ST s b) -> [a] -> [b]
  mapST f (x:xs) = runST (f x) : mapST f xs
  mapST f [] = []

By your reasoning, (f x) should have type forall s . ST s b, and
should match what runST expects, but apparently GHC complains
about it. Why?

-- 
Regards,
Paul Liu

Yale Haskell Group
http://www.haskell.org/yale


More information about the Haskell-Cafe mailing list