... for the same reason as this one doesn't get through: import Control.Monad.ST import Data.Array.ST main = print $ runST $ do return ()
... but this one does: import Control.Monad.ST import Data.Array.ST main = print $ runST ( do return ()) it's all about rank-2 types; see SPJ's et al. paper on type inference for these types. However, I guess that the jury is still out, say this specific rank-2 behavior may be revised (and I also hope so). HTH Ralf > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:haskell-cafe- > [EMAIL PROTECTED] On Behalf Of Bulat Ziganshin > Sent: Tuesday, January 03, 2006 2:28 AM > To: haskell-cafe@haskell.org > Subject: [Haskell-cafe] ST monad > > Hello > > the following code can't go through typechecking. can anyone help me > to fix it or, better, let me know what i need to read to fix it myself? :) > > import Control.Monad.ST > import Data.Array.ST > main = print $ runST $ > do arr <- newArray (1,10) 127 > a <- readArray arr 1 > writeArray arr 1 216 > b <- readArray arr 1 > return (a,b) > > > PS: error message is > > b.hs:4:15: > Inferred type is less polymorphic than expected > Quantified type variable `s' escapes > Expected type: ST s a -> b > Inferred type: (forall s1. ST s1 a) -> a > In the first argument of `($)', namely `runST' > In the second argument of `($)', namely > `runST > $ (do > arr <- newArray (1, 10) 127 > a <- readArray arr 1 > writeArray arr 1 216 > b <- readArray arr 1 > return (a, b))' > > > > -- > Best regards, > Bulat mailto:[EMAIL PROTECTED] > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe