Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HFunctor h where
- class HFunctor sig => Effect sig where
- class (HFunctor sig, Monad m) => Carrier sig m | m -> sig where
- eff :: sig m a -> m a
- send :: (Member effect sig, Carrier sig m) => effect m a -> m a
- handlePure :: (HFunctor sig, Functor f) => (forall x. f x -> g x) -> sig f a -> sig g a
- handleCoercible :: (HFunctor sig, Functor f, Coercible f g) => sig f a -> sig g a
- class GHFunctor m m' rep rep' where
- class GEffect m m' rep rep' where
- run :: PureC a -> a
- data (f :+: g) (m :: * -> *) k
- class Member (sub :: (* -> *) -> * -> *) sup where
Documentation
class HFunctor h where Source #
Higher-order functors of kind (* -> *) -> (* -> *)
map functors to functors.
All effects must be HFunctor
s.
Nothing
fmap' :: Functor (h f) => (a -> b) -> h f a -> h f b Source #
Deprecated: fmap' has been subsumed by fmap.
Apply a handler specified as a natural transformation to both higher-order and continuation positions within an HFunctor
.
hmap :: Functor m => (forall x. m x -> n x) -> h m a -> h n a Source #
Higher-order functor map of a natural transformation over higher-order positions within the effect.
A definition for hmap
over first-order effects can be derived automatically provided a Generic1
instance is available.
hmap :: (Functor m, Generic1 (h m), Generic1 (h n), GHFunctor m n (Rep1 (h m)) (Rep1 (h n))) => (forall x. m x -> n x) -> h m a -> h n a Source #
Instances
HFunctor Pure Source # | |
HFunctor Resource Source # | |
HFunctor Random Source # | |
HFunctor NonDet Source # | |
HFunctor Fresh Source # | |
HFunctor Fail Source # | |
HFunctor Cut Source # | |
HFunctor Cull Source # | |
HFunctor Trace Source # | |
HFunctor (State s) Source # | |
HFunctor (Reader r) Source # | |
Functor sig => HFunctor (Lift sig) Source # | |
HFunctor (Error exc) Source # | |
HFunctor (Resumable err) Source # | |
HFunctor (Writer w) Source # | |
(HFunctor f, HFunctor g) => HFunctor (f :+: g) Source # | |
class HFunctor sig => Effect sig where Source #
The class of effect types, which must:
- Be functorial in their last two arguments, and
- Support threading effects in higher-order positions through using the carrier’s suspended state.
All first-order effects (those without existential occurrences of m
) admit a default definition of handle
provided a Generic1
instance is available for the effect.
Nothing
handle :: (Functor f, Monad m) => f () -> (forall x. f (m x) -> n (f x)) -> sig m a -> sig n (f a) Source #
Handle any effects in a signature by threading the carrier’s state all the way through to the continuation.
handle :: (Functor f, Monad m, Generic1 (sig m), Generic1 (sig n), GEffect m n (Rep1 (sig m)) (Rep1 (sig n))) => f () -> (forall x. f (m x) -> n (f x)) -> sig m a -> sig n (f a) Source #
Handle any effects in a signature by threading the carrier’s state all the way through to the continuation.
Instances
Effect Pure Source # | |
Effect Resource Source # | |
Effect Random Source # | |
Effect NonDet Source # | |
Effect Fresh Source # | |
Effect Fail Source # | |
Effect Cut Source # | |
Effect Cull Source # | |
Effect Trace Source # | |
Effect (State s) Source # | |
Effect (Reader r) Source # | |
Functor sig => Effect (Lift sig) Source # | |
Effect (Error exc) Source # | |
Effect (Resumable err) Source # | |
Effect (Writer w) Source # | |
(Effect f, Effect g) => Effect (f :+: g) Source # | |
class (HFunctor sig, Monad m) => Carrier sig m | m -> sig where Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff
method.
eff :: sig m a -> m a Source #
Construct a value in the carrier for an effect signature (typically a sum of a handled effect and any remaining effects).
Instances
send :: (Member effect sig, Carrier sig m) => effect m a -> m a Source #
Construct a request for an effect to be interpreted by some handler later on.
handlePure :: (HFunctor sig, Functor f) => (forall x. f x -> g x) -> sig f a -> sig g a Source #
Deprecated: handlePure has been subsumed by hmap.
Apply a handler specified as a natural transformation to both higher-order and continuation positions within an HFunctor
.
Generic deriving of HFunctor
& Effect
instances.
class GHFunctor m m' rep rep' where Source #
Generic implementation of HFunctor
.
ghmap :: Functor m => (forall x. m x -> m' x) -> rep a -> rep' a Source #
Generic implementation of hmap
.
Instances
GHFunctor m m' Par1 Par1 Source # | |
GHFunctor m m' (U1 :: Type -> Type) (U1 :: Type -> Type) Source # | |
GHFunctor m m' (V1 :: Type -> Type) (V1 :: Type -> Type) Source # | |
HFunctor f => GHFunctor m m' (Rec1 (f m)) (Rec1 (f m')) Source # | |
GHFunctor m m' (Rec1 m) (Rec1 m') Source # | |
GHFunctor m m' (K1 R c :: Type -> Type) (K1 R c :: Type -> Type) Source # | |
(GHFunctor m m' l l', GHFunctor m m' r r') => GHFunctor m m' (l :*: r) (l' :*: r') Source # | |
(GHFunctor m m' l l', GHFunctor m m' r r') => GHFunctor m m' (l :+: r) (l' :+: r') Source # | |
(Functor f, GHFunctor m m' g g') => GHFunctor m m' (f :.: g) (f :.: g') Source # | |
GHFunctor m m' rep rep' => GHFunctor m m' (M1 i c rep) (M1 i c rep') Source # | |
class GEffect m m' rep rep' where Source #
Generic implementation of Effect
.
ghandle :: (Functor f, Monad m) => f () -> (forall x. f (m x) -> m' (f x)) -> rep a -> rep' (f a) Source #
Generic implementation of handle
.
Instances
GEffect m m' Par1 Par1 Source # | |
GEffect m m' (U1 :: Type -> Type) (U1 :: Type -> Type) Source # | |
GEffect m m' (V1 :: Type -> Type) (V1 :: Type -> Type) Source # | |
Effect f => GEffect m m' (Rec1 (f m)) (Rec1 (f m')) Source # | |
GEffect m m' (Rec1 m) (Rec1 m') Source # | |
GEffect m m' (K1 R c :: Type -> Type) (K1 R c :: Type -> Type) Source # | |
(GEffect m m' l l', GEffect m m' r r') => GEffect m m' (l :*: r) (l' :*: r') Source # | |
(GEffect m m' l l', GEffect m m' r r') => GEffect m m' (l :+: r) (l' :+: r') Source # | |
(Functor f, GEffect m m' g g') => GEffect m m' (f :.: g) (f :.: g') Source # | |
GEffect m m' rep rep' => GEffect m m' (M1 i c rep) (M1 i c rep') Source # | |
Re-exports
data (f :+: g) (m :: * -> *) k infixr 4 Source #
Instances
Member sub sup => Member sub (sub' :+: sup) Source # | |
Member sub (sub :+: sup) Source # | |
Generic1 ((f :+: g) m :: Type -> Type) Source # | |
(Effect f, Effect g) => Effect (f :+: g) Source # | |
(HFunctor f, HFunctor g) => HFunctor (f :+: g) Source # | |
(Carrier sig m, MonadIO m) => Carrier (Resource :+: sig) (ResourceC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (NonDet :+: sig) (NonDetC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (NonDet :+: sig) (OnceC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Fresh :+: sig) (FreshC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Fail :+: sig) (FailC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Cut :+: (NonDet :+: sig)) (CutC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Cull :+: (NonDet :+: sig)) (CullC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Trace :+: sig) (TraceByReturningC m) Source # | |
Defined in Control.Effect.Trace eff :: (Trace :+: sig) (TraceByReturningC m) a -> TraceByReturningC m a Source # | |
Carrier sig m => Carrier (Trace :+: sig) (TraceByIgnoringC m) Source # | |
Defined in Control.Effect.Trace eff :: (Trace :+: sig) (TraceByIgnoringC m) a -> TraceByIgnoringC m a Source # | |
(MonadIO m, Carrier sig m) => Carrier (Trace :+: sig) (TraceByPrintingC m) Source # | |
Defined in Control.Effect.Trace eff :: (Trace :+: sig) (TraceByPrintingC m) a -> TraceByPrintingC m a Source # | |
(HFunctor eff, Carrier sig m) => Carrier (eff :+: sig) (InterpretC eff m) Source # | |
Defined in Control.Effect.Interpret eff :: (eff :+: sig) (InterpretC eff m) a -> InterpretC eff m a Source # | |
(Carrier sig m, Effect sig) => Carrier (State s :+: sig) (StateC s m) Source # | |
(Carrier sig m, Effect sig) => Carrier (State s :+: sig) (StateC s m) Source # | |
Carrier sig m => Carrier (Reader r :+: sig) (ReaderC r m) Source # | |
(Carrier sig m, Effect sig, RandomGen g) => Carrier (Random :+: sig) (RandomC g m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Error e :+: sig) (ErrorC e m) Source # | |
Carrier sig m => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # | |
Defined in Control.Effect.Resumable eff :: (Resumable err :+: sig) (ResumableWithC err m) a -> ResumableWithC err m a Source # | |
(Carrier sig m, Effect sig) => Carrier (Resumable err :+: sig) (ResumableC err m) Source # | |
Defined in Control.Effect.Resumable eff :: (Resumable err :+: sig) (ResumableC err m) a -> ResumableC err m a Source # | |
(Monoid w, Carrier sig m, Effect sig) => Carrier (Writer w :+: sig) (WriterC w m) Source # | |
(HFunctor eff, Carrier sig m, Effect sig) => Carrier (eff :+: sig) (InterpretStateC eff s m) Source # | |
Defined in Control.Effect.Interpret eff :: (eff :+: sig) (InterpretStateC eff s m) a -> InterpretStateC eff s m a Source # | |
(Functor (f m), Functor (g m)) => Functor ((f :+: g) m) Source # | |
(Foldable (f m), Foldable (g m)) => Foldable ((f :+: g) m) Source # | |
Defined in Control.Effect.Sum fold :: Monoid m0 => (f :+: g) m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> (f :+: g) m a -> m0 # foldr :: (a -> b -> b) -> b -> (f :+: g) m a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) m a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) m a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) m a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) m a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) m a -> a # toList :: (f :+: g) m a -> [a] # null :: (f :+: g) m a -> Bool # length :: (f :+: g) m a -> Int # elem :: Eq a => a -> (f :+: g) m a -> Bool # maximum :: Ord a => (f :+: g) m a -> a # minimum :: Ord a => (f :+: g) m a -> a # | |
(Traversable (f m), Traversable (g m)) => Traversable ((f :+: g) m) Source # | |
Defined in Control.Effect.Sum | |
(Eq (f m k), Eq (g m k)) => Eq ((f :+: g) m k) Source # | |
(Ord (f m k), Ord (g m k)) => Ord ((f :+: g) m k) Source # | |
Defined in Control.Effect.Sum compare :: (f :+: g) m k -> (f :+: g) m k -> Ordering # (<) :: (f :+: g) m k -> (f :+: g) m k -> Bool # (<=) :: (f :+: g) m k -> (f :+: g) m k -> Bool # (>) :: (f :+: g) m k -> (f :+: g) m k -> Bool # (>=) :: (f :+: g) m k -> (f :+: g) m k -> Bool # | |
(Show (f m k), Show (g m k)) => Show ((f :+: g) m k) Source # | |
type Rep1 ((f :+: g) m :: Type -> Type) Source # | |
Defined in Control.Effect.Sum type Rep1 ((f :+: g) m :: Type -> Type) = D1 (MetaData ":+:" "Control.Effect.Sum" "fused-effects-0.5.0.0-inplace" False) (C1 (MetaCons "L" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (f m))) :+: C1 (MetaCons "R" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (g m)))) |