Skip to content

Commit 4d57942

Browse files
iohk-bors[bot]coot
andauthored
Merge #3172
3172: Fix signature of `Control.Monad.Class.MonadSTM.Strict.stateTVar` r=coot a=coot This PR requires a careful review. There are various places where ``` stateTVar :: MonadSTM m => StrictTVar m s -> (s -> (s, s)) -> STM m s ``` is used, and thus the change made is not visible in types. `IOLike` module in consensus exports `Control.Monad.Class.MonadSTM.Strict` so this inlucdes all the places in consensus which use it. - io-sim-classes: fix type signature of `Strict.stateTVar` - Updated call sites of `Strict.stateTVar` Co-authored-by: Marcin Szamotulski <[email protected]>
2 parents 42b27c9 + a92c5f4 commit 4d57942

File tree

1 file changed

+3
-3
lines changed
  • io-sim-classes/src/Control/Monad/Class/MonadSTM

1 file changed

+3
-3
lines changed

io-sim-classes/src/Control/Monad/Class/MonadSTM/Strict.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ writeTVar StrictTVar { tvar, invariant } !a =
138138
modifyTVar :: MonadSTM m => StrictTVar m a -> (a -> a) -> STM m ()
139139
modifyTVar v f = readTVar v >>= writeTVar v . f
140140

141-
stateTVar :: MonadSTM m => StrictTVar m a -> (a -> (a, b)) -> STM m b
141+
stateTVar :: MonadSTM m => StrictTVar m s -> (s -> (a, s)) -> STM m a
142142
stateTVar v f = do
143143
a <- readTVar v
144-
let (a', b) = f a
144+
let (b, a') = f a
145145
writeTVar v a'
146146
return b
147147

@@ -152,7 +152,7 @@ swapTVar v a' = do
152152
return a
153153

154154

155-
updateTVar :: MonadSTM m => StrictTVar m a -> (a -> (a, b)) -> STM m b
155+
updateTVar :: MonadSTM m => StrictTVar m s -> (s -> (a, s)) -> STM m a
156156
updateTVar = stateTVar
157157
{-# DEPRECATED updateTVar "Use stateTVar" #-}
158158

0 commit comments

Comments
 (0)