classy-effects-base-0.1.0.1: An interface for a handler-independent, typeclass-based effect system.
Copyright(c) 2023 Yamada Ryo
(c) 2023 Casper Bach Poulsen and Cas van der Rest
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

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

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).

type (~>) f g = forall x. f x -> g x Source #

A natural transformation.

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.

Constructors

LiftIns 

Fields

Instances

Instances details
HFunctor (LiftIns ins) Source # 
Instance details

Defined in Control.Effect.Class

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> LiftIns ins f :-> LiftIns ins g #

SendIns ins f => SendSig (LiftIns ins) f Source # 
Instance details

Defined in Control.Effect.Class

Methods

sendSig :: LiftIns ins f a -> f a Source #

Foldable ins => Foldable (LiftIns ins f) Source # 
Instance details

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 #

sum :: Num a => LiftIns ins f a -> a #

product :: Num a => LiftIns ins f a -> a #

Traversable ins => Traversable (LiftIns ins f) Source # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Methods

fmap :: (a -> b) -> LiftIns ins f a -> LiftIns ins f b #

(<$) :: a -> LiftIns ins f b -> LiftIns ins f a #

class SendIns (ins :: Instruction) f where Source #

A type class that represents the ability to send an instruction ins to carrier f.

Methods

sendIns :: ins a -> f a Source #

Send an instruction ins to carrier f.

Instances

Instances details
SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

sendIns :: ins a -> ViaTag EffectDataHandler tag f a Source #

type (<:) = SendIns Source #

The operator version of SendIns.

class SendSig (sig :: Signature) f where Source #

A type class that represents the ability to send a signature sig to carrier f.

Methods

sendSig :: sig f a -> f a Source #

Send a signature sig to carrier f.

Instances

Instances details
(SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

(SendSig (sig ## tag) (EffectsVia EffectDataHandler f), HFunctor sig) => SendSig sig (ViaTag EffectDataHandler tag f) Source # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Methods

sendSig :: LiftIns ins f a -> f a Source #

type (<<:) = SendIns Source #

The operator version of SendSig.

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

Instances details
SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

(SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

MonadFail f => MonadFail (EffectsVia handlerSystem f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

fail :: String -> EffectsVia handlerSystem f a #

MonadFix f => MonadFix (EffectsVia handlerSystem f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

mfix :: (a -> EffectsVia handlerSystem f a) -> EffectsVia handlerSystem f a #

MonadIO f => MonadIO (EffectsVia handlerSystem f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

liftIO :: IO a -> EffectsVia handlerSystem f a #

Alternative f => Alternative (EffectsVia handlerSystem f) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Associated Types

type Tagged (EffectsVia handlerSystem f) tag :: Type -> Type Source #

Methods

unTagged :: Tagged (EffectsVia handlerSystem f) tag a -> EffectsVia handlerSystem f a Source #

type Tagged (EffectsVia handlerSystem f) tag Source # 
Instance details

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.

Constructors

ViaTag 

Fields

Instances

Instances details
SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Methods

fail :: String -> ViaTag handlerSystem tag f a #

MonadFix f => MonadFix (ViaTag handlerSystem tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

mfix :: (a -> ViaTag handlerSystem tag f a) -> ViaTag handlerSystem tag f a #

MonadIO f => MonadIO (ViaTag handlerSystem tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

liftIO :: IO a -> ViaTag handlerSystem tag f a #

Alternative f => Alternative (ViaTag handlerSystem tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

empty :: ViaTag handlerSystem tag f a #

(<|>) :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f a #

some :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f [a] #

many :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f [a] #

Applicative f => Applicative (ViaTag handlerSystem tag f) Source # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Methods

fmap :: (a -> b) -> ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f b #

(<$) :: a -> ViaTag handlerSystem tag f b -> ViaTag handlerSystem tag f a #

Monad f => Monad (ViaTag handlerSystem tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

(>>=) :: ViaTag handlerSystem tag f a -> (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 b #

return :: a -> ViaTag handlerSystem tag f a #

MonadPlus f => MonadPlus (ViaTag handlerSystem tag f) Source # 
Instance details

Defined in Control.Effect.Class

Methods

mzero :: ViaTag handlerSystem tag f a #

mplus :: ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f a -> ViaTag handlerSystem tag f a #

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

Instances details
SendIns ins f => SendIns ins (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

(SendSig sig f, HFunctor sig) => SendSig sig (EffectsVia EffectDataHandler f) Source # 
Instance details

Defined in Control.Effect.Class

SendIns (ins # tag) (EffectsVia EffectDataHandler f) => SendIns ins (ViaTag EffectDataHandler tag f) Source # 
Instance details

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 # 
Instance details

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

Instances details
Taggable (EffectsVia handlerSystem f) Source # 
Instance details

Defined in Control.Effect.Class

Associated Types

type Tagged (EffectsVia handlerSystem f) tag :: Type -> Type Source #

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.

type (@#) f tag = Tagged f tag Source #

A wrapper type to send to carrier f with the specified tag.

newtype Tag (ins :: Instruction) tag a Source #

Tagged instruction class.

Constructors

Tag 

Fields

Instances

Instances details
Foldable ins => Foldable (Tag ins tag) Source # 
Instance details

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 #

sum :: Num a => Tag ins tag a -> a #

product :: Num a => Tag ins tag a -> a #

Traversable ins => Traversable (Tag ins tag) Source # 
Instance details

Defined in Control.Effect.Class

Methods

traverse :: Applicative f => (a -> f b) -> Tag ins tag a -> f (Tag ins tag b) #

sequenceA :: Applicative f => Tag ins tag (f a) -> f (Tag ins tag a) #

mapM :: Monad m => (a -> m b) -> Tag ins tag a -> m (Tag ins tag b) #

sequence :: Monad m => Tag ins tag (m a) -> m (Tag ins tag a) #

Functor ins => Functor (Tag ins tag) Source # 
Instance details

Defined in Control.Effect.Class

Methods

fmap :: (a -> b) -> Tag ins tag a -> Tag ins tag b #

(<$) :: a -> Tag ins tag b -> Tag ins tag a #

type (#) = Tag Source #

Tagged instruction class.

pattern T :: forall tag ins a. ins a -> Tag ins tag a Source #

Tagged instruction class.

newtype TagH (sig :: Signature) tag f a Source #

Tagged signature class.

Constructors

TagH 

Fields

Instances

Instances details
HFunctor sig => HFunctor (TagH sig tag) Source # 
Instance details

Defined in Control.Effect.Class

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> TagH sig tag f :-> TagH sig tag g #

Foldable (sig f) => Foldable (TagH sig tag f) Source # 
Instance details

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 #

sum :: Num a => TagH sig tag f a -> a #

product :: Num a => TagH sig tag f a -> a #

Traversable (sig f) => Traversable (TagH sig tag f) Source # 
Instance details

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 # 
Instance details

Defined in Control.Effect.Class

Methods

fmap :: (a -> b) -> TagH sig tag f a -> TagH sig tag f b #

(<$) :: a -> TagH sig tag f b -> TagH sig tag f a #

type (##) = TagH Source #

Tagged signature class.

pattern TH :: forall tag sig f a. sig f a -> TagH sig tag f a Source #

Tagged signature class.

class Nop (f :: Type -> Type) Source #

An effect class with no effects.

Instances

Instances details
Nop f Source # 
Instance details

Defined in Control.Effect.Class

data NopI (a :: Type) Source #

An instruction class with no effects.

Instances

Instances details
Foldable NopI Source # 
Instance details

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 #

toList :: NopI a -> [a] #

null :: NopI a -> Bool #

length :: NopI a -> Int #

elem :: Eq a => a -> NopI a -> Bool #

maximum :: Ord a => NopI a -> a #

minimum :: Ord a => NopI a -> a #

sum :: Num a => NopI a -> a #

product :: Num a => NopI a -> a #

Traversable NopI Source # 
Instance details

Defined in Control.Effect.Class

Methods

traverse :: Applicative f => (a -> f b) -> NopI a -> f (NopI b) #

sequenceA :: Applicative f => NopI (f a) -> f (NopI a) #

mapM :: Monad m => (a -> m b) -> NopI a -> m (NopI b) #

sequence :: Monad m => NopI (m a) -> m (NopI a) #

Functor NopI Source # 
Instance details

Defined in Control.Effect.Class

Methods

fmap :: (a -> b) -> NopI a -> NopI b #

(<$) :: a -> NopI b -> NopI a #

type NopS = LiftIns NopI Source #

A signature class with no effects.