Skip to content

Commit

Permalink
Add getAndModify to StrictStateT
Browse files Browse the repository at this point in the history
  • Loading branch information
christiaanb committed May 23, 2011
1 parent 9d142a4 commit 5172288
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clash/Data/Accessor/Monad/Trans/StrictState.hs
Expand Up @@ -14,6 +14,12 @@ get f = State.gets (Accessor.get f)
modify :: Monad m => Accessor.T r a -> (a -> a) -> StateT r m ()
modify f g = State.modify (Accessor.modify f g)

getAndModify :: Monad m => Accessor.T r a -> (a -> a) -> StateT r m a
getAndModify f g =
do x <- get f
modify f g
return x

infix 1 %=, %:

(%=) :: Monad m => Accessor.T r a -> a -> StateT r m ()
Expand Down

0 comments on commit 5172288

Please sign in to comment.