monadology-0.4: The best ideas in monad-related classes and types.
Safe HaskellNone
LanguageGHC2021

Control.Monad.Ology.Data.Ref

Synopsis

Documentation

data Ref (m :: Type -> Type) a Source #

A reference of a monad (as in StateT).

Constructors

MkRef 

Fields

Instances

Instances details
Functor m => Invariant (Ref m) Source # 
Instance details

Defined in Control.Monad.Ology.Data.Ref

Methods

invmap :: (a -> b) -> (b -> a) -> Ref m a -> Ref m b #

Applicative m => Productable (Ref m) Source # 
Instance details

Defined in Control.Monad.Ology.Data.Ref

Methods

rUnit :: Ref m () #

(<***>) :: Ref m a -> Ref m b -> Ref m (a, b) #

(***>) :: Ref m () -> Ref m a -> Ref m a #

(<***) :: Ref m a -> Ref m () -> Ref m a #

refModify :: Monad m => Ref m a -> (a -> a) -> m () Source #

refModifyM :: Monad m => Ref m a -> (a -> m a) -> m () Source #

refRestore :: forall (m :: Type -> Type) a. MonadException m => Ref m a -> m --> m Source #

Restore the original value of this reference after the operation.

refPutRestore :: forall (m :: Type -> Type) a. MonadException m => Ref m a -> a -> m --> m Source #

Put and restore the original value of this reference after the operation.

lensMapRef :: forall (m :: Type -> Type) a b. Monad m => Lens' a b -> Ref m a -> Ref m b Source #

liftRef :: forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type). (MonadTrans t, Monad m) => Ref m --> Ref (t m) Source #

stateRef :: forall (m :: Type -> Type) s. Monad m => Ref (StateT s m) s Source #

refRunState :: forall (m :: Type -> Type) s. Monad m => Ref m s -> StateT s m --> m Source #

Run a state monad over this reference.

ioRef :: IORef a -> Ref IO a Source #

strictSTRef :: STRef s a -> Ref (ST s) a Source #

lazySTRef :: STRef s a -> Ref (ST s) a Source #

refParam :: forall (m :: Type -> Type) a. MonadException m => Ref m a -> Param m a Source #

Use a reference as a parameter.

refProd :: forall (m :: Type -> Type) a. (MonadException m, Monoid a) => Ref m a -> Prod m a Source #

Use a reference as a product.