{- | Access helper functions in a State monad -}moduleData.Accessor.MonadStatewhereimportqualifiedData.Accessor.BasicasAccessorimportqualifiedControl.Monad.Trans.StateasStateimportqualifiedControl.Monad.TransasTransimportControl.Monad.Trans.State(State,runState,StateT(runStateT),)importControl.Monad.Trans(MonadTrans)-- * accessors in the form of actions in the state monadset::Monadm=>Accessor.Tra->a->StateTrm()setfx=State.modify(Accessor.setfx)get::Monadm=>Accessor.Tra->StateTrmagetf=State.gets(Accessor.getf)modify::Monadm=>Accessor.Tra->(a->a)->StateTrm()modifyfg=State.modify(Accessor.modifyfg){- |
Modify a record element and return its old value.
-}getAndModify::Monadm=>Accessor.Tra->(a->a)->StateTrmagetAndModifyfg=dox<-getfmodifyfgreturnx{- |
Modify a record element and return its new value.
-}modifyAndGet::Monadm=>Accessor.Tra->(a->a)->StateTrmamodifyAndGetfg=domodifyfggetfinfix1%=,%:{- |
Infix variant of 'set'.
-}(%=)::Monadm=>Accessor.Tra->a->StateTrm()(%=)=set{- |
Infix variant of 'modify'.
-}(%:)::Monadm=>Accessor.Tra->(a->a)->StateTrm()(%:)=modify-- * lift a state monadic accessor to an accessor of a parent recordlift::Monadm=>Accessor.Trs->Statesa->StateTrmaliftfm=dos0<-getflet(a,s1)=runStatems0setfs1returnaliftT::(Monadm)=>Accessor.Trs->StateTsma->StateTrmaliftTfm=dos0<-getf(a,s1)<-Trans.lift$runStateTms0setfs1returna