Skip to content

Commit

Permalink
Return modified value from modify
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed May 23, 2018
1 parent 4a64b5a commit c1b9a0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Control/Monad/ST/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ foreign import read :: forall a r. STRef r a -> ST r a
foreign import modify' :: forall r a b. (a -> { state :: a, value :: b }) -> STRef r a -> ST r b

-- | Modify the value of a mutable reference by applying a function to the
-- | current value.
modify :: forall r a. (a -> a) -> STRef r a -> ST r Unit
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' }

-- | Set the value of a mutable reference.
foreign import write :: forall a r. a -> STRef r a -> ST r a

0 comments on commit c1b9a0d

Please sign in to comment.