in-other-words-0.2.0.0: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Unlift

Synopsis

Effects

newtype Unlift b :: Effect where Source #

A helper primitive effect for unlifting to a base monad.

Helper primitive effects are effects that allow you to avoid interpreting one of your own effects as a primitive if the power needed from direct access to the underlying monad can instead be provided by the relevant helper primitive effect. The reason why you'd want to do this is that helper primitive effects already have ThreadsEff instances defined for them, so you don't have to define any for your own effect.

The helper primitive effects offered in this library are -- in order of ascending power -- Regional, Optional, BaseControl and Unlift.

Unlift is typically used as a primitive effect. If you define a Carrier that relies on a novel non-trivial monad transformer t, then you need to make a ThreadsEff t (Unlift b) instance (if possible). threadUnliftViaClass can help you with that.

The following threading constraints accept Unlift:

Constructors

Unlift :: forall b m a. ((forall x. m x -> b x) -> b a) -> Unlift b m a 

Instances

Instances details
Carrier m => PrimHandler UnliftH (Unlift m) m Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

ThreadsEff (ReaderT i) (Unlift b) Source # 
Instance details

Defined in Control.Effect.Type.Unlift

Methods

threadEff :: Monad m => (forall x. Unlift b m x -> m x) -> Unlift b (ReaderT i m) a -> ReaderT i m a Source #

Actions

unlift :: Eff (Unlift b) m => ((forall x. m x -> b x) -> b a) -> m a Source #

Interpretations

class (MonadBaseControl b m, forall x. Pure m x) => MonadBaseControlPure b m Source #

A constraint synonym for MonadBaseControl b m together with that StM m a ~ a for all a.

Instances

Instances details
(MonadBaseControl b m, forall x. Pure m x) => MonadBaseControlPure b m Source # 
Instance details

Defined in Control.Effect.Type.Unlift

unliftToFinal :: (MonadBaseControlPure b m, Carrier m) => UnliftToFinalC b m a -> m a Source #

Run a Unlift b effect, where the unlifted monad b is the final base monad of m

Derivs (UnliftToFinalC b m) = Unlift b ': Derivs m
Prims  (UnliftToFinalC b m) = Unlift b ': Prims m

runUnlift :: Carrier m => UnliftC m a -> m a Source #

Run a Unlift m effect, where the unlifted monad m is the current monad.

Derivs (UnliftC m) = Unlift m ': Derivs m
Prims  (UnliftC m) = Unlift m ': Prims m

Threading utilities

threadUnliftViaClass :: forall b t m a. (MonadTransControlPure t, Monad m) => (forall x. Unlift b m x -> m x) -> Unlift b (t m) a -> t m a Source #

A valid definition of threadEff for a ThreadsEff (Unlift b) t instance, given that t is a MonadTransControl where StT t a ~ a holds for all a.

Combinators for Algebras

powerAlgUnlift :: forall m p a. Algebra' p m a -> Algebra' (Unlift m ': p) m a Source #

Strengthen an Algebra p m by adding a Unlift m handler

powerAlgUnliftFinal :: forall b m p a. MonadBaseControlPure b m => Algebra' p m a -> Algebra' (Unlift b ': p) m a Source #

Strengthen an Algebra p m by adding a Unlift b handler, where b is the final base monad.

Carriers

type UnliftToFinalC b = InterpretPrimC UnliftToFinalH (Unlift b) Source #

data UnliftC m a Source #

Instances

Instances details
MonadTrans (UnliftC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

lift :: Monad m => m a -> UnliftC m a #

MonadTransControl (UnliftC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Associated Types

type StT UnliftC a #

Methods

liftWith :: Monad m => (Run UnliftC -> m a) -> UnliftC m a #

restoreT :: Monad m => m (StT UnliftC a) -> UnliftC m a #

Monad m => Monad (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

(>>=) :: UnliftC m a -> (a -> UnliftC m b) -> UnliftC m b #

(>>) :: UnliftC m a -> UnliftC m b -> UnliftC m b #

return :: a -> UnliftC m a #

Functor m => Functor (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

fmap :: (a -> b) -> UnliftC m a -> UnliftC m b #

(<$) :: a -> UnliftC m b -> UnliftC m a #

MonadFix m => MonadFix (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

mfix :: (a -> UnliftC m a) -> UnliftC m a #

MonadFail m => MonadFail (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

fail :: String -> UnliftC m a #

Applicative m => Applicative (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

pure :: a -> UnliftC m a #

(<*>) :: UnliftC m (a -> b) -> UnliftC m a -> UnliftC m b #

liftA2 :: (a -> b -> c) -> UnliftC m a -> UnliftC m b -> UnliftC m c #

(*>) :: UnliftC m a -> UnliftC m b -> UnliftC m b #

(<*) :: UnliftC m a -> UnliftC m b -> UnliftC m a #

MonadIO m => MonadIO (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

liftIO :: IO a -> UnliftC m a #

Alternative m => Alternative (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

empty :: UnliftC m a #

(<|>) :: UnliftC m a -> UnliftC m a -> UnliftC m a #

some :: UnliftC m a -> UnliftC m [a] #

many :: UnliftC m a -> UnliftC m [a] #

MonadPlus m => MonadPlus (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

mzero :: UnliftC m a #

mplus :: UnliftC m a -> UnliftC m a -> UnliftC m a #

MonadThrow m => MonadThrow (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

throwM :: Exception e => e -> UnliftC m a #

MonadCatch m => MonadCatch (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

catch :: Exception e => UnliftC m a -> (e -> UnliftC m a) -> UnliftC m a #

MonadMask m => MonadMask (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Methods

mask :: ((forall a. UnliftC m a -> UnliftC m a) -> UnliftC m b) -> UnliftC m b #

uninterruptibleMask :: ((forall a. UnliftC m a -> UnliftC m a) -> UnliftC m b) -> UnliftC m b #

generalBracket :: UnliftC m a -> (a -> ExitCase b -> UnliftC m c) -> (a -> UnliftC m b) -> UnliftC m (b, c) #

Carrier m => Carrier (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Associated Types

type Derivs (UnliftC m) :: [Effect] Source #

type Prims (UnliftC m) :: [Effect] Source #

type StT (UnliftC :: (Type -> Type) -> Type -> Type) a Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

type StT (UnliftC :: (Type -> Type) -> Type -> Type) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

type Prims (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift