We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a64b5a commit c1b9a0dCopy full SHA for c1b9a0d
src/Control/Monad/ST/Internal.purs
@@ -101,9 +101,9 @@ foreign import read :: forall a r. STRef r a -> ST r a
101
foreign import modify' :: forall r a b. (a -> { state :: a, value :: b }) -> STRef r a -> ST r b
102
103
-- | Modify the value of a mutable reference by applying a function to the
104
--- | current value.
105
-modify :: forall r a. (a -> a) -> STRef r a -> ST r Unit
106
-modify f = modify' (\s -> { state: f s, value: unit })
+-- | current value. The modified value is returned.
+modify :: forall r a. (a -> a) -> STRef r a -> ST r a
+modify f = modify' \s -> let s' = f s in { state: s', value: s' }
107
108
-- | Set the value of a mutable reference.
109
foreign import write :: forall a r. a -> STRef r a -> ST r a
0 commit comments