module Data.Label.PureM
(
gets
, puts
, modify
, (=:)
, (=.)
, asks
, local
)
where
import Data.Label.Pure ((:->))
import qualified Control.Monad.Reader as M
import qualified Control.Monad.State as M
import qualified Data.Label.Pure as L
gets :: M.MonadState s m => s :-> a -> m a
gets = M.gets . L.get
puts :: M.MonadState s m => s :-> a -> a -> m ()
puts l = M.modify . L.set l
modify :: M.MonadState s m => s :-> a -> (a -> a) -> m ()
modify l = M.modify . L.modify l
infixr 2 =:
(=:) :: M.MonadState s m => s :-> a -> a -> m ()
(=:) = puts
infixr 2 =.
(=.) :: M.MonadState s m => s :-> a -> (a -> a) -> m ()
(=.) = modify
asks :: M.MonadReader r m => (r :-> a) -> m a
asks = M.asks . L.get
local :: M.MonadReader r m => (r :-> b) -> (b -> b) -> m a -> m a
local l f = M.local (L.modify l f)