module Data.Accessor
( Accessor, accessor,
setVal, (Accessor.^=), getVal, (Accessor.^.), (Accessor.^:),
getA, putA, (=:), (State.%=), modA, (State.%:),
(.>), (<.),
)
where
import qualified Data.Accessor.Basic as Accessor
import qualified Data.Accessor.MonadStatePrivate as State
import Control.Monad.Trans.State (StateT, )
type Accessor r a = Accessor.T r a
accessor ::
(r -> a)
-> (a -> r -> r)
-> Accessor r a
accessor = flip Accessor.fromSetGet
getVal ::
Accessor r a
-> r
-> a
getVal = Accessor.get
setVal ::
Accessor r a
-> a
-> r
-> r
setVal = Accessor.set
infixl 9 .>
(.>) :: Accessor a b -> Accessor b c -> Accessor a c
(.>) = (Accessor..>)
infixr 9 <.
(<.) :: Accessor b c -> Accessor a b -> Accessor a c
(<.) = (Accessor.<.)
infix 1 =:
{-# DEPRECATED (=:) "use (Data.Accessor.Monad.Trans.State.%=) from data-accessor-transformers package" #-}
(=:) :: Monad m => Accessor r a -> a -> StateT r m ()
(=:) = putA
{-# DEPRECATED getA "Data.Accessor.Monad.Trans.State.get from data-accessor-transformers package" #-}
getA :: Monad m => Accessor r a -> StateT r m a
getA = State.get
{-# DEPRECATED putA "Data.Accessor.Monad.Trans.State.set from data-accessor-transformers package" #-}
putA :: Monad m => Accessor r a -> a -> StateT r m ()
putA = State.set
{-# DEPRECATED modA "Data.Accessor.Monad.Trans.State.modify from data-accessor-transformers package" #-}
modA :: Monad m => Accessor r a -> (a -> a) -> StateT r m ()
modA = State.modify