newtype vs data TC problem
The following module stops with TC problems, but if
you replace the newtype with data, things work fine.
This problem is in the HEAD, but not in 5.00
Andy
module State2 (StateM, runStateM, genUniqM) where
import ST
newtype StateM a = StateM (forall s . STRef s Int ->
ST s a)
runStateM :: StateM a -> Int -> (a,Int)
runStateM (StateM fn) u =
runST (do { uRef <- newSTRef u
; res <- fn uRef
; u <- readSTRef uRef
; return (res,u)
})
unStateM :: StateM a -> STRef b Int -> ST b a
unStateM (StateM fn) u = fn u
genUniqM :: StateM Int
genUniqM = StateM (\ uRef -> do { u <- readSTRef uRef
; writeSTRef uRef (u+1)
; return u
})
instance Monad StateM where
return a = StateM (\ uRef -> return a)
m >>= k = StateM (\ uRef -> do { r <- unStateM m
uRef
; unStateM (k r) uRef
})
Trac metadata
Trac field |
Value |
Version |
5.0 |
Type |
Bug |
TypeOfFailure |
OtherFailure |
Priority |
normal |
Resolution |
ResolvedFixed |
Component |
Compiler (Type checker) |
Test case |
|
Differential revisions |
|
BlockedBy |
|
Related |
|
Blocking |
|
CC |
|
Operating system |
|
Architecture |
|