Created
August 26, 2011 10:30
-
-
Save maoe/1173157 to your computer and use it in GitHub Desktop.
MonoLocalBindsの影響
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MonoLocalBinds, ScopedTypeVariables #-} | |
module MonoLocalBinds where | |
import Control.Monad.ST | |
import Data.STRef | |
f :: forall a. a -> ((a, Char), (a, Bool)) | |
f x = (g 'v', g True) | |
where | |
g :: b -> (a, b) -- コメントアウトするとgはgeneralizeされない | |
g y = (x, y) | |
foo :: forall a. Bool -> a -> a -> a | |
foo b x y = runST $ do { r <- newSTRef x; fill r; readSTRef r } | |
where | |
fill :: STRef s a -> ST s () -- コメントアウトするとfillはgeneralizeされない | |
fill r = case b of | |
True -> return () | |
False -> writeSTRef r y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment