{-# LANGUAGE BlockArguments, RequiredTypeArguments #-} module LocalSigsST where import Data.STRef import Control.Monad.ST -- Haskell2010 doit1 :: Int doit1 = runST do x <- newSTRef 0 let mogrify :: STRef s Int -> ST s () mogrify y = modifySTRef y succ mogrify x readSTRef x -- ScopedTypeVariables doit2 :: Int doit2 = runST do (x :: STRef s Int) <- newSTRef 0 let mogrify :: ST s () mogrify = modifySTRef x succ mogrify readSTRef x -- RequiredTypeArguments doit3 :: Int doit3 = runST' \s -> do x <- newSTRef 0 let mogrify :: ST s () mogrify = modifySTRef x succ mogrify readSTRef x runST' :: (forall s -> ST s a) -> a runST' f = runST (unreq f) where unreq :: forall t a. (forall s -> ST s a) -> ST t a unreq f = f t