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

Control.Effect.Union

Synopsis

Effects

data Union (r :: [Effect]) m a where Source #

An effect for collecting multiple effects into one effect.

Behind the scenes, Union is the most important effect in the entire library, as the Carrier class is built around handling Unions of effects.

However, even outside of defining novel Carrier instances, Union can be useful as an effect in its own right. Union is useful for effect newtypes -- effects defined through creating a newtype over an existing effect. By making a newtype of Union, it's possible to wrap multiple effects in one newtype.

Not to be confused with Bundle. Unlike Bundle, Union is a proper effect that is given no special treatment by Eff or Effs.

Constructors

Union :: Coercible z m => ElemOf e r -> e z a -> Union r m a 

data ElemOf (e :: a) (r :: [a]) where Source #

Constructors

Here :: ElemOf e (e ': r) 
There :: ElemOf e r -> ElemOf e (_e ': r) 

Instances

Instances details
Show (ElemOf e r) Source # 
Instance details

Defined in Control.Effect.Internal.Membership

Methods

showsPrec :: Int -> ElemOf e r -> ShowS #

show :: ElemOf e r -> String #

showList :: [ElemOf e r] -> ShowS #

Actions

unionize :: (Eff (Union b) m, KnownList b) => UnionizeC b m a -> m a Source #

Sends uses of effects in b to a Union b effect.

Derivs (UnionizeC b m) = b ++ Derivs m

unionizeHead :: (HeadEff (Union b) m, KnownList b) => UnionizeHeadC b m a -> m a Source #

Rewrite uses of effects in b into a Union b effect on top of the effect stack.

Derivs (UnionizeHeadC b m) = b ++ StripPrefix '[Union b] (Derivs m)

Interpretations

runUnion :: forall b m a. (HeadEffs b m, KnownList b) => UnionC b m a -> m a Source #

Run an Union b effect by placing the effects of b on top of the effect stack.

Derivs (UnionC b m) = Union b ': StripPrefix b (Derivs m)
Prims  (UnionC b m) = Prims m

Utilities

inj :: Member e r => e m a -> Union r m a Source #

Inject an effect into a Union containing that effect.

decomp :: RepresentationalEff e => Union (e ': r) m a -> Either (Union r m a) (e m a) Source #

extract :: RepresentationalEff e => Union '[e] m a -> e m a Source #

Extract the only effect of an Union.

weaken :: Union r m a -> Union (e ': r) m a Source #

absurdU :: Union '[] m a -> b Source #

absurdMember :: ElemOf e '[] -> b Source #

Carriers

data UnionizeC b m a Source #

Instances

Instances details
MonadBase b' m => MonadBase b' (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftBase :: b' α -> UnionizeC b m α #

MonadBaseControl b' m => MonadBaseControl b' (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StM (UnionizeC b m) a #

Methods

liftBaseWith :: (RunInBase (UnionizeC b m) b' -> b' a) -> UnionizeC b m a #

restoreM :: StM (UnionizeC b m) a -> UnionizeC b m a #

MonadTrans (UnionizeC b :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Methods

lift :: Monad m => m a -> UnionizeC b m a #

MonadTransControl (UnionizeC b :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StT (UnionizeC b) a #

Methods

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

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

Monad m => Monad (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

(>>=) :: UnionizeC b m a -> (a -> UnionizeC b m b0) -> UnionizeC b m b0 #

(>>) :: UnionizeC b m a -> UnionizeC b m b0 -> UnionizeC b m b0 #

return :: a -> UnionizeC b m a #

Functor m => Functor (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fmap :: (a -> b0) -> UnionizeC b m a -> UnionizeC b m b0 #

(<$) :: a -> UnionizeC b m b0 -> UnionizeC b m a #

MonadFix m => MonadFix (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mfix :: (a -> UnionizeC b m a) -> UnionizeC b m a #

MonadFail m => MonadFail (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fail :: String -> UnionizeC b m a #

Applicative m => Applicative (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

pure :: a -> UnionizeC b m a #

(<*>) :: UnionizeC b m (a -> b0) -> UnionizeC b m a -> UnionizeC b m b0 #

liftA2 :: (a -> b0 -> c) -> UnionizeC b m a -> UnionizeC b m b0 -> UnionizeC b m c #

(*>) :: UnionizeC b m a -> UnionizeC b m b0 -> UnionizeC b m b0 #

(<*) :: UnionizeC b m a -> UnionizeC b m b0 -> UnionizeC b m a #

MonadIO m => MonadIO (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftIO :: IO a -> UnionizeC b m a #

Alternative m => Alternative (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

empty :: UnionizeC b m a #

(<|>) :: UnionizeC b m a -> UnionizeC b m a -> UnionizeC b m a #

some :: UnionizeC b m a -> UnionizeC b m [a] #

many :: UnionizeC b m a -> UnionizeC b m [a] #

MonadPlus m => MonadPlus (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mzero :: UnionizeC b m a #

mplus :: UnionizeC b m a -> UnionizeC b m a -> UnionizeC b m a #

MonadThrow m => MonadThrow (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

throwM :: Exception e => e -> UnionizeC b m a #

MonadCatch m => MonadCatch (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

MonadMask m => MonadMask (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

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

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

(KnownList b, Eff (Union b) m) => Carrier (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type Derivs (UnionizeC b m) :: [Effect] Source #

type Prims (UnionizeC b m) :: [Effect] Source #

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

Defined in Control.Effect.Union

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

Defined in Control.Effect.Union

type Derivs (UnionizeC b m) = Append b (Derivs m)
type Prims (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

type Prims (UnionizeC b m) = Prims m
type StM (UnionizeC b m) a Source # 
Instance details

Defined in Control.Effect.Union

type StM (UnionizeC b m) a = StM m a

data UnionizeHeadC b m a Source #

Instances

Instances details
MonadBase b' m => MonadBase b' (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftBase :: b' α -> UnionizeHeadC b m α #

MonadBaseControl b' m => MonadBaseControl b' (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StM (UnionizeHeadC b m) a #

Methods

liftBaseWith :: (RunInBase (UnionizeHeadC b m) b' -> b' a) -> UnionizeHeadC b m a #

restoreM :: StM (UnionizeHeadC b m) a -> UnionizeHeadC b m a #

MonadTrans (UnionizeHeadC b :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Methods

lift :: Monad m => m a -> UnionizeHeadC b m a #

MonadTransControl (UnionizeHeadC b :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StT (UnionizeHeadC b) a #

Methods

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

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

Monad m => Monad (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

(>>=) :: UnionizeHeadC b m a -> (a -> UnionizeHeadC b m b0) -> UnionizeHeadC b m b0 #

(>>) :: UnionizeHeadC b m a -> UnionizeHeadC b m b0 -> UnionizeHeadC b m b0 #

return :: a -> UnionizeHeadC b m a #

Functor m => Functor (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fmap :: (a -> b0) -> UnionizeHeadC b m a -> UnionizeHeadC b m b0 #

(<$) :: a -> UnionizeHeadC b m b0 -> UnionizeHeadC b m a #

MonadFix m => MonadFix (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mfix :: (a -> UnionizeHeadC b m a) -> UnionizeHeadC b m a #

MonadFail m => MonadFail (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fail :: String -> UnionizeHeadC b m a #

Applicative m => Applicative (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

pure :: a -> UnionizeHeadC b m a #

(<*>) :: UnionizeHeadC b m (a -> b0) -> UnionizeHeadC b m a -> UnionizeHeadC b m b0 #

liftA2 :: (a -> b0 -> c) -> UnionizeHeadC b m a -> UnionizeHeadC b m b0 -> UnionizeHeadC b m c #

(*>) :: UnionizeHeadC b m a -> UnionizeHeadC b m b0 -> UnionizeHeadC b m b0 #

(<*) :: UnionizeHeadC b m a -> UnionizeHeadC b m b0 -> UnionizeHeadC b m a #

MonadIO m => MonadIO (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftIO :: IO a -> UnionizeHeadC b m a #

Alternative m => Alternative (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

empty :: UnionizeHeadC b m a #

(<|>) :: UnionizeHeadC b m a -> UnionizeHeadC b m a -> UnionizeHeadC b m a #

some :: UnionizeHeadC b m a -> UnionizeHeadC b m [a] #

many :: UnionizeHeadC b m a -> UnionizeHeadC b m [a] #

MonadPlus m => MonadPlus (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mzero :: UnionizeHeadC b m a #

mplus :: UnionizeHeadC b m a -> UnionizeHeadC b m a -> UnionizeHeadC b m a #

MonadThrow m => MonadThrow (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

throwM :: Exception e => e -> UnionizeHeadC b m a #

MonadCatch m => MonadCatch (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

MonadMask m => MonadMask (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

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

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

(HeadEff (Union b) m, KnownList b) => Carrier (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type Derivs (UnionizeHeadC b m) :: [Effect] Source #

type Prims (UnionizeHeadC b m) :: [Effect] Source #

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

Defined in Control.Effect.Union

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

Defined in Control.Effect.Union

type Prims (UnionizeHeadC b m) Source # 
Instance details

Defined in Control.Effect.Union

type Prims (UnionizeHeadC b m) = Prims m
type StM (UnionizeHeadC b m) a Source # 
Instance details

Defined in Control.Effect.Union

type StM (UnionizeHeadC b m) a = StM m a

data UnionC (l :: [Effect]) m a Source #

Instances

Instances details
MonadBase b m => MonadBase b (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftBase :: b α -> UnionC l m α #

MonadBaseControl b m => MonadBaseControl b (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StM (UnionC l m) a #

Methods

liftBaseWith :: (RunInBase (UnionC l m) b -> b a) -> UnionC l m a #

restoreM :: StM (UnionC l m) a -> UnionC l m a #

MonadTrans (UnionC l :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Methods

lift :: Monad m => m a -> UnionC l m a #

MonadTransControl (UnionC l :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StT (UnionC l) a #

Methods

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

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

Monad m => Monad (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

(>>=) :: UnionC l m a -> (a -> UnionC l m b) -> UnionC l m b #

(>>) :: UnionC l m a -> UnionC l m b -> UnionC l m b #

return :: a -> UnionC l m a #

Functor m => Functor (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fmap :: (a -> b) -> UnionC l m a -> UnionC l m b #

(<$) :: a -> UnionC l m b -> UnionC l m a #

MonadFix m => MonadFix (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mfix :: (a -> UnionC l m a) -> UnionC l m a #

MonadFail m => MonadFail (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

fail :: String -> UnionC l m a #

Applicative m => Applicative (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

pure :: a -> UnionC l m a #

(<*>) :: UnionC l m (a -> b) -> UnionC l m a -> UnionC l m b #

liftA2 :: (a -> b -> c) -> UnionC l m a -> UnionC l m b -> UnionC l m c #

(*>) :: UnionC l m a -> UnionC l m b -> UnionC l m b #

(<*) :: UnionC l m a -> UnionC l m b -> UnionC l m a #

MonadIO m => MonadIO (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

liftIO :: IO a -> UnionC l m a #

Alternative m => Alternative (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

empty :: UnionC l m a #

(<|>) :: UnionC l m a -> UnionC l m a -> UnionC l m a #

some :: UnionC l m a -> UnionC l m [a] #

many :: UnionC l m a -> UnionC l m [a] #

MonadPlus m => MonadPlus (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

mzero :: UnionC l m a #

mplus :: UnionC l m a -> UnionC l m a -> UnionC l m a #

MonadThrow m => MonadThrow (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

throwM :: Exception e => e -> UnionC l m a #

MonadCatch m => MonadCatch (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

MonadMask m => MonadMask (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Methods

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

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

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

(KnownList l, HeadEffs l m) => Carrier (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type Derivs (UnionC l m) :: [Effect] Source #

type Prims (UnionC l m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (UnionC l m)) (UnionC l m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (UnionC l m)) (Prims (UnionC l m)) (UnionC l m) z a Source #

algDerivs :: Algebra' (Derivs (UnionC l m)) (UnionC l m) a Source #

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

Defined in Control.Effect.Union

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

Defined in Control.Effect.Union

type Derivs (UnionC l m) = Union l ': StripPrefix l (Derivs m)
type Prims (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

type Prims (UnionC l m) = Prims m
type StM (UnionC l m) a Source # 
Instance details

Defined in Control.Effect.Union

type StM (UnionC l m) a = StM m a