| Copyright | (c) 2023 Yamada Ryo (c) 2023 Casper Bach Poulsen and Cas van der Rest |
|---|---|
| License | MPL-2.0 (see the file LICENSE) |
| Maintainer | ymdfield@outlook.jp |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Control.Effect.Class
Description
This module provides the essential definitions required for CEPs compliance, forming the foundation of classy-effects. Please refer to CEPs for details.
Synopsis
- type Signature = (Type -> Type) -> Type -> Type
- type Instruction = Type -> Type
- type (~>) f g = forall x. f x -> g x
- newtype LiftIns (ins :: Instruction) (f :: Type -> Type) a = LiftIns {
- unliftIns :: ins a
- class SendIns (ins :: Instruction) f where
- sendIns :: ins a -> f a
- type (<:) = SendIns
- class SendSig (sig :: Signature) f where
- sendSig :: sig f a -> f a
- type (<<:) = SendIns
- newtype EffectsVia handlerSystem (f :: Type -> Type) a = EffectsVia {
- runEffectsVia :: f a
- newtype ViaTag handlerSystem tag (f :: Type -> Type) a = ViaTag {
- runViaTag :: f a
- data EffectDataHandler
- class Taggable f where
- tag :: forall tag f a. Taggable f => Tagged f tag a -> f a
- type (@#) f tag = Tagged f tag
- newtype Tag (ins :: Instruction) tag a = Tag {
- getTag :: ins a
- type (#) = Tag
- pattern T :: forall tag ins a. ins a -> Tag ins tag a
- newtype TagH (sig :: Signature) tag f a = TagH {
- getTagH :: sig f a
- type (##) = TagH
- pattern TH :: forall tag sig f a. sig f a -> TagH sig tag f a
- class Nop (f :: Type -> Type)
- data NopI (a :: Type)
- type NopS = LiftIns NopI
Documentation
type Signature = (Type -> Type) -> Type -> Type Source #
A kind of signature class (a datatype of higher-order effect).
type Instruction = Type -> Type Source #
A kind of instruction class (a datatype of first-order effect).
newtype LiftIns (ins :: Instruction) (f :: Type -> Type) a Source #
Lift an instruction class to a signature class.
Come from heft-lang/POPL2023/haskell/src/Elab.hs.
Instances
| HFunctor (LiftIns ins) Source # | |
| SendIns ins f => SendSig (LiftIns ins) f Source # | |
Defined in Control.Effect.Class | |
| Foldable ins => Foldable (LiftIns ins f) Source # | |
Defined in Control.Effect.Class Methods fold :: Monoid m => LiftIns ins f m -> m # foldMap :: Monoid m => (a -> m) -> LiftIns ins f a -> m # foldMap' :: Monoid m => (a -> m) -> LiftIns ins f a -> m # foldr :: (a -> b -> b) -> b -> LiftIns ins f a -> b # foldr' :: (a -> b -> b) -> b -> LiftIns ins f a -> b # foldl :: (b -> a -> b) -> b -> LiftIns ins f a -> b # foldl' :: (b -> a -> b) -> b -> LiftIns ins f a -> b # foldr1 :: (a -> a -> a) -> LiftIns ins f a -> a # foldl1 :: (a -> a -> a) -> LiftIns ins f a -> a # toList :: LiftIns ins f a -> [a] # null :: LiftIns ins f a -> Bool # length :: LiftIns ins f a -> Int # elem :: Eq a => a -> LiftIns ins f a -> Bool # maximum :: Ord a => LiftIns ins f a -> a # minimum :: Ord a => LiftIns ins f a -> a # | |
| Traversable ins => Traversable (LiftIns ins f) Source # | |
Defined in Control.Effect.Class Methods traverse :: Applicative f0 => (a -> f0 b) -> LiftIns ins f a -> f0 (LiftIns ins f b) # sequenceA :: Applicative f0 => LiftIns ins f (f0 a) -> f0 (LiftIns ins f a) # mapM :: Monad m => (a -> m b) -> LiftIns ins f a -> m (LiftIns ins f b) # sequence :: Monad m => LiftIns ins f (m a) -> m (LiftIns ins f a) # | |
| Functor ins => Functor (LiftIns ins f) Source # | |
class SendIns (ins :: Instruction) f where Source #
A type class that represents the ability to send an instruction ins to carrier f.
Instances
| SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> EffectsVia EffectDataHandler f a Source # | |
| SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> ViaTag EffectDataHandler tag f a Source # | |
class SendSig (sig :: Signature) f where Source #
A type class that represents the ability to send a signature sig to carrier f.
Instances
| (SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (EffectsVia EffectDataHandler f) a -> EffectsVia EffectDataHandler f a Source # | |
| (SendSig (sig ## tag) (EffectsVia EffectDataHandler f), HFunctor sig) => SendSig sig (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (ViaTag EffectDataHandler tag f) a -> ViaTag EffectDataHandler tag f a Source # | |
| SendIns ins f => SendSig (LiftIns ins) f Source # | |
Defined in Control.Effect.Class | |
newtype EffectsVia handlerSystem (f :: Type -> Type) a Source #
A wrapper data type to integrate a backend handler system into the classy-effects framework.
Constructors
| EffectsVia | |
Fields
| |
Instances
| SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> EffectsVia EffectDataHandler f a Source # | |
| (SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (EffectsVia EffectDataHandler f) a -> EffectsVia EffectDataHandler f a Source # | |
| MonadFail f => MonadFail (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods fail :: String -> EffectsVia handlerSystem f a # | |
| MonadFix f => MonadFix (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods mfix :: (a -> EffectsVia handlerSystem f a) -> EffectsVia handlerSystem f a # | |
| MonadIO f => MonadIO (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods liftIO :: IO a -> EffectsVia handlerSystem f a # | |
| Alternative f => Alternative (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods empty :: EffectsVia handlerSystem f a # (<|>) :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f a -> EffectsVia handlerSystem f a # some :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f [a] # many :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f [a] # | |
| Applicative f => Applicative (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods pure :: a -> EffectsVia handlerSystem f a # (<*>) :: EffectsVia handlerSystem f (a -> b) -> EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b # liftA2 :: (a -> b -> c) -> EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b -> EffectsVia handlerSystem f c # (*>) :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b -> EffectsVia handlerSystem f b # (<*) :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b -> EffectsVia handlerSystem f a # | |
| Functor f => Functor (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods fmap :: (a -> b) -> EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b # (<$) :: a -> EffectsVia handlerSystem f b -> EffectsVia handlerSystem f a # | |
| Monad f => Monad (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods (>>=) :: EffectsVia handlerSystem f a -> (a -> EffectsVia handlerSystem f b) -> EffectsVia handlerSystem f b # (>>) :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f b -> EffectsVia handlerSystem f b # return :: a -> EffectsVia handlerSystem f a # | |
| MonadPlus f => MonadPlus (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods mzero :: EffectsVia handlerSystem f a # mplus :: EffectsVia handlerSystem f a -> EffectsVia handlerSystem f a -> EffectsVia handlerSystem f a # | |
| Taggable (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods unTagged :: Tagged (EffectsVia handlerSystem f) tag a -> EffectsVia handlerSystem f a Source # | |
| type Tagged (EffectsVia handlerSystem f) tag Source # | |
Defined in Control.Effect.Class type Tagged (EffectsVia handlerSystem f) tag = EffectsVia handlerSystem (ViaTag handlerSystem tag f) | |
newtype ViaTag handlerSystem tag (f :: Type -> Type) a Source #
A wrapper data type to represent sending an effect to the carrier f with the specified tag.
Instances
| SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> ViaTag EffectDataHandler tag f a Source # | |
| (SendSig (sig ## tag) (EffectsVia EffectDataHandler f), HFunctor sig) => SendSig sig (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (ViaTag EffectDataHandler tag f) a -> ViaTag EffectDataHandler tag f a Source # | |
| MonadFail f => MonadFail (ViaTag handlerSystem tag f) Source # | |
Defined in Control.Effect.Class | |
| MonadFix f => MonadFix (ViaTag handlerSystem tag f) Source # | |
Defined in Control.Effect.Class | |
| MonadIO f => MonadIO (ViaTag handlerSystem tag f) Source # | |
Defined in Control.Effect.Class | |
| Alternative f => Alternative (ViaTag handlerSystem tag f) Source # | |
Defined in Control.Effect.Class | |
| Applicative f => Applicative (ViaTag handlerSystem tag f) Source # | |
Defined in Control.Effect.Class Methods pure :: a -> ViaTag handlerSystem tag f a # (<*>) :: ViaTag handlerSystem tag f (a -> b) -> ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f b # liftA2 :: (a -> b -> c) -> ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f b -> ViaTag handlerSystem tag f c # (*>) :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f b -> ViaTag handlerSystem tag f b # (<*) :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f b -> ViaTag handlerSystem tag f a # | |
| Functor f => Functor (ViaTag handlerSystem tag f) Source # | |
| Monad f => Monad (ViaTag handlerSystem tag f) Source # | |
| MonadPlus f => MonadPlus (ViaTag handlerSystem tag f) Source # | |
data EffectDataHandler Source #
A backend identifier type tag to represent the mechanism of sending effects to a carrier using
SendIns/SendSig based on CEP-02.
Instances
| SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> EffectsVia EffectDataHandler f a Source # | |
| (SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (EffectsVia EffectDataHandler f) a -> EffectsVia EffectDataHandler f a Source # | |
| SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendIns :: ins a -> ViaTag EffectDataHandler tag f a Source # | |
| (SendSig (sig ## tag) (EffectsVia EffectDataHandler f), HFunctor sig) => SendSig sig (ViaTag EffectDataHandler tag f) Source # | |
Defined in Control.Effect.Class Methods sendSig :: sig (ViaTag EffectDataHandler tag f) a -> ViaTag EffectDataHandler tag f a Source # | |
class Taggable f where Source #
A type class representing the carrier f capable of sending tagged effects.
Associated Types
type Tagged f tag :: Type -> Type Source #
A wrapper type to send to carrier f with the specified tag.
Methods
unTagged :: Tagged f tag a -> f a Source #
Send all effects within the scope, tagged, to carrier f.
Instances
| Taggable (EffectsVia handlerSystem f) Source # | |
Defined in Control.Effect.Class Methods unTagged :: Tagged (EffectsVia handlerSystem f) tag a -> EffectsVia handlerSystem f a Source # | |
tag :: forall tag f a. Taggable f => Tagged f tag a -> f a Source #
Send all effects within the scope, tagged, to carrier f.
newtype Tag (ins :: Instruction) tag a Source #
Tagged instruction class.
Instances
| Foldable ins => Foldable (Tag ins tag) Source # | |
Defined in Control.Effect.Class Methods fold :: Monoid m => Tag ins tag m -> m # foldMap :: Monoid m => (a -> m) -> Tag ins tag a -> m # foldMap' :: Monoid m => (a -> m) -> Tag ins tag a -> m # foldr :: (a -> b -> b) -> b -> Tag ins tag a -> b # foldr' :: (a -> b -> b) -> b -> Tag ins tag a -> b # foldl :: (b -> a -> b) -> b -> Tag ins tag a -> b # foldl' :: (b -> a -> b) -> b -> Tag ins tag a -> b # foldr1 :: (a -> a -> a) -> Tag ins tag a -> a # foldl1 :: (a -> a -> a) -> Tag ins tag a -> a # toList :: Tag ins tag a -> [a] # null :: Tag ins tag a -> Bool # length :: Tag ins tag a -> Int # elem :: Eq a => a -> Tag ins tag a -> Bool # maximum :: Ord a => Tag ins tag a -> a # minimum :: Ord a => Tag ins tag a -> a # | |
| Traversable ins => Traversable (Tag ins tag) Source # | |
Defined in Control.Effect.Class | |
| Functor ins => Functor (Tag ins tag) Source # | |
newtype TagH (sig :: Signature) tag f a Source #
Tagged signature class.
Instances
| HFunctor sig => HFunctor (TagH sig tag) Source # | |
| Foldable (sig f) => Foldable (TagH sig tag f) Source # | |
Defined in Control.Effect.Class Methods fold :: Monoid m => TagH sig tag f m -> m # foldMap :: Monoid m => (a -> m) -> TagH sig tag f a -> m # foldMap' :: Monoid m => (a -> m) -> TagH sig tag f a -> m # foldr :: (a -> b -> b) -> b -> TagH sig tag f a -> b # foldr' :: (a -> b -> b) -> b -> TagH sig tag f a -> b # foldl :: (b -> a -> b) -> b -> TagH sig tag f a -> b # foldl' :: (b -> a -> b) -> b -> TagH sig tag f a -> b # foldr1 :: (a -> a -> a) -> TagH sig tag f a -> a # foldl1 :: (a -> a -> a) -> TagH sig tag f a -> a # toList :: TagH sig tag f a -> [a] # null :: TagH sig tag f a -> Bool # length :: TagH sig tag f a -> Int # elem :: Eq a => a -> TagH sig tag f a -> Bool # maximum :: Ord a => TagH sig tag f a -> a # minimum :: Ord a => TagH sig tag f a -> a # | |
| Traversable (sig f) => Traversable (TagH sig tag f) Source # | |
Defined in Control.Effect.Class Methods traverse :: Applicative f0 => (a -> f0 b) -> TagH sig tag f a -> f0 (TagH sig tag f b) # sequenceA :: Applicative f0 => TagH sig tag f (f0 a) -> f0 (TagH sig tag f a) # mapM :: Monad m => (a -> m b) -> TagH sig tag f a -> m (TagH sig tag f b) # sequence :: Monad m => TagH sig tag f (m a) -> m (TagH sig tag f a) # | |
| Functor (sig f) => Functor (TagH sig tag f) Source # | |
class Nop (f :: Type -> Type) Source #
An effect class with no effects.
Instances
| Nop f Source # | |
Defined in Control.Effect.Class | |
data NopI (a :: Type) Source #
An instruction class with no effects.
Instances
| Foldable NopI Source # | |
Defined in Control.Effect.Class Methods fold :: Monoid m => NopI m -> m # foldMap :: Monoid m => (a -> m) -> NopI a -> m # foldMap' :: Monoid m => (a -> m) -> NopI a -> m # foldr :: (a -> b -> b) -> b -> NopI a -> b # foldr' :: (a -> b -> b) -> b -> NopI a -> b # foldl :: (b -> a -> b) -> b -> NopI a -> b # foldl' :: (b -> a -> b) -> b -> NopI a -> b # foldr1 :: (a -> a -> a) -> NopI a -> a # foldl1 :: (a -> a -> a) -> NopI a -> a # elem :: Eq a => a -> NopI a -> Bool # maximum :: Ord a => NopI a -> a # | |
| Traversable NopI Source # | |
| Functor NopI Source # | |