monad-control-identity-0.2.0.0: Stronger classes than monad-control
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Trans.Control.Identity

Synopsis

MonadTransControlIdentity

class MonadTransControl t => MonadTransControlIdentity t where Source #

The MonadTransControlIdentity type class is a stronger version of MonadTransControl:

MonadTransControl instances are aware of the monadic state of the transformer and allow to save and restore this state. MonadTransControlIdentity instances on the other hand exist only for exactly those transformers, that don't have any monadic state.

So for any instance of this class this should hold:

forall a. StT t a ~ a

This can't be given as a constraint to the class due to limitations regarding the TypeFamilies extension.

Methods

liftWithIdentity :: Monad m => ((forall x. t m x -> m x) -> m a) -> t m a Source #

Instances

Instances details
MonadTransControlIdentity (IdentityT :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftWithIdentity :: Monad m => ((forall x. IdentityT m x -> m x) -> m a) -> IdentityT m a Source #

MonadTransControlIdentity (ReaderT r) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftWithIdentity :: Monad m => ((forall x. ReaderT r m x -> m x) -> m a) -> ReaderT r m a Source #

MonadTransControlIdentity instances can easily be created for monad transformers, because of the superclass MonadTransControl:

newtype ExampleT = ...
  deriving (Monad, MonadTrans)

instance MonadTransControl ExampleT where
  ...

instance MonadTransControlIdentity ExampleT where
  liftWithIdentity f = liftWith $ \ runT -> f runT

MonadBaseControlIdentity

Regarding the IO base monad this can be seen as an alternative, but equivalent, way to implement MonadUnliftIO.

class MonadBaseControl b m => MonadBaseControlIdentity b m | m -> b where Source #

The MonadBaseControlIdentity type class is a stronger version of MonadBaseControl.

Just like MonadTransControlIdentity instances of MonadBaseControlIdentity hold no monadic state:

forall a. StM m a ~ a

Methods

liftBaseWithIdentity :: ((forall x. m x -> b x) -> b a) -> m a Source #

Instances

Instances details
MonadBaseControlIdentity Identity Identity Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. Identity x -> Identity x) -> Identity a) -> Identity a Source #

MonadBaseControlIdentity STM STM Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. STM x -> STM x) -> STM a) -> STM a Source #

MonadBaseControlIdentity IO IO Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. IO x -> IO x) -> IO a) -> IO a Source #

MonadBaseControlIdentity Maybe Maybe Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. Maybe x -> Maybe x) -> Maybe a) -> Maybe a Source #

MonadBaseControlIdentity [] [] Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. [x] -> [x]) -> [a]) -> [a] Source #

MonadBaseControlIdentity b m => MonadBaseControlIdentity b (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. IdentityT m x -> b x) -> b a) -> IdentityT m a Source #

MonadBaseControlIdentity b m => MonadBaseControlIdentity b (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. ReaderT r m x -> b x) -> b a) -> ReaderT r m a Source #

MonadBaseControlIdentity (ST s) (ST s) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. ST s x -> ST s x) -> ST s a) -> ST s a Source #

MonadBaseControlIdentity (Either e) (Either e) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. Either e x -> Either e x) -> Either e a) -> Either e a Source #

MonadBaseControlIdentity (ST s) (ST s) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. ST s x -> ST s x) -> ST s a) -> ST s a Source #

MonadBaseControlIdentity ((->) r) ((->) r) Source # 
Instance details

Defined in Control.Monad.Trans.Control.Identity

Methods

liftBaseWithIdentity :: ((forall x. (r -> x) -> r -> x) -> r -> a) -> r -> a Source #

MonadBaseControlIdentity instances can be created just as easily for monad transformers:

instance MonadBaseControlIdentity b m => MonadBaseControlIdentity b (ExampleT m) where
  liftBaseWithIdentity = defaultLiftBaseWithIdentity

defaultLiftBaseWithIdentity :: (MonadBaseControlIdentity b m, MonadTransControlIdentity t) => ((forall x. t m x -> b x) -> b a) -> t m a Source #