Skip to content

Commit 0d9a1f9

Browse files
committed
Have modify return the updated value
1 parent 7a0e347 commit 0d9a1f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Effect/Ref.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ foreign import read :: forall s. Ref s -> Effect s
2525
foreign import modify' :: forall s b. (s -> { state :: s, value :: b }) -> Ref s -> Effect b
2626

2727
-- | Update the value of a mutable reference by applying a function
28-
-- | to the current value.
29-
modify :: forall s. (s -> s) -> Ref s -> Effect Unit
30-
modify f = modify' (\s -> { state: f s, value: unit })
28+
-- | to the current value. The updated value is returned.
29+
modify :: forall s. (s -> s) -> Ref s -> Effect s
30+
modify f = modify' \s -> let s' = f s in { state: s', value: s' }
3131

3232
-- | Update the value of a mutable reference to the specified value.
3333
foreign import write :: forall s. s -> Ref s -> Effect Unit

0 commit comments

Comments
 (0)