Skip to content

Commit

Permalink
Merge pull request #110 from purescript/modify_
Browse files Browse the repository at this point in the history
Add modify_
  • Loading branch information
garyb authored May 27, 2018
2 parents 6a64dd6 + c3e4c3c commit 87bd95f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Control/Monad/RWS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Prelude

import Control.Monad.Reader.Class (ask, asks, local) as Exports
import Control.Monad.RWS.Trans (class MonadTrans, RWSResult(..), RWST(..), evalRWST, execRWST, lift, mapRWST, runRWST, withRWST)
import Control.Monad.State.Class (get, gets, state, put, modify) as Exports
import Control.Monad.State.Class (get, gets, state, put, modify, modify_) as Exports
import Control.Monad.Trans.Class (lift) as Exports
import Control.Monad.Writer.Class (censor, listen, listens, pass, tell) as Exports

Expand Down
2 changes: 1 addition & 1 deletion src/Control/Monad/State.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Control.Monad.State

import Prelude

import Control.Monad.State.Class (class MonadState, get, gets, modify, put, state)
import Control.Monad.State.Class (class MonadState, get, gets, modify, modify_, put, state)
import Control.Monad.State.Trans (class MonadTrans, StateT(..), evalStateT, execStateT, lift, mapStateT, runStateT, withStateT)

import Data.Identity (Identity(..))
Expand Down
3 changes: 3 additions & 0 deletions src/Control/Monad/State/Class.purs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ put s = state \_ -> Tuple unit s
-- | value is the new state value.
modify :: forall s m. MonadState s m => (s -> s) -> m s
modify f = state \s -> let s' = f s in Tuple s' s'

modify_ :: forall s m. MonadState s m => (s -> s) -> m Unit
modify_ f = state \s -> Tuple unit (f s)
2 changes: 1 addition & 1 deletion src/Control/Monad/State/Trans.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Control.Monad.Cont.Class (class MonadCont, callCC)
import Control.Monad.Error.Class (class MonadThrow, class MonadError, catchError, throwError)
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader, ask, local)
import Control.Monad.Rec.Class (class MonadRec, tailRecM, Step(..))
import Control.Monad.State.Class (class MonadState, get, gets, modify, put, state)
import Control.Monad.State.Class (class MonadState, get, gets, modify, modify_, put, state)
import Control.Monad.Trans.Class (class MonadTrans, lift)
import Control.Monad.Writer.Class (class MonadWriter, class MonadTell, pass, listen, tell)
import Control.MonadPlus (class MonadPlus)
Expand Down

0 comments on commit 87bd95f

Please sign in to comment.