[Haskell-cafe] Re: Composing functions with runST

David House dmhouse at gmail.com
Mon Jan 1 08:45:34 EST 2007

On 01/01/07, Yitzchak Gale <gale at sefer.org> wrote:
> It seems that I can't even use STRefs.
> Something is really wrong here.
> Prelude Control.Monad.ST Data.STRef> runST $ do {r<-newSTRef 2; readSTRef r}

Again, this is due to section 7.4.8 [1] of the GHC user manual, which
states that you can't instantiate a type variable with a type
involving a forall. You're trying to unify the first parameter of ($)
:: a -> b -> a with (forall s. ST s a -> a), which is illegal. Using
parentheses works:

runST (do r <- newSTRef 2; readSTRef r)

However, I'm as much in the dark as you are as to _why_ this is illegal.

[1]: http://haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#universal-quantification

-David House, dmhouse at gmail.com

More information about the Haskell-Cafe mailing list