Copyright | (c) 2023-2024 Sayo contributors |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | [email protected] |
Safe Haskell | None |
Language | GHC2021 |
Data.Effect
Description
Synopsis
- type Effect = (Type -> Type) -> Type -> Type
- data EffectOrder
- type family OrderOf (e :: Effect) :: EffectOrder
- type family OrderCase (o :: EffectOrder) (a :: k) (b :: k) :: k where ...
- data EffectForm
- type family FormOf (e :: Effect) :: EffectForm
- type family FormCase (f :: EffectForm) (a :: k) (b :: k) :: k where ...
- type family LabelOf (e :: Effect)
- class (OrderOf e ~ 'FirstOrder, forall (f :: Type -> Type) (g :: Type -> Type) a. Coercible (e f a) (e g a)) => FirstOrder (e :: Effect)
- class FormOf e ~ 'Polynomial => PolyHFunctor (e :: Effect)
- data Nop (a :: Type -> Type) b
- data NopLabel
- newtype Emb (e :: Type -> Type) (f :: Type -> Type) a = Emb {
- getEmb :: e a
- data EmbLabel (e :: Type -> Type)
- newtype Unemb (e :: k -> k1 -> Type) (a :: k1) = Unemb {
- getUnemb :: forall (f :: k). e f a
- data Ask r (a :: Type -> Type) b where
- data AskLabel
- data Local r (a :: Type -> Type) b where
- data LocalLabel
- data State s (a :: Type -> Type) b where
- data StateLabel
- data Tell w (a :: Type -> Type) b where
- data TellLabel
- data WriterH w (a :: Type -> Type) b where
- data WriterHLabel
- data Throw e (a :: Type -> Type) b where
- data ThrowLabel
- data Catch e (a :: Type -> Type) b where
- data CatchLabel
- data Empty (a :: Type -> Type) b where
- data EmptyLabel
- data Choose (a :: Type -> Type) b where
- data ChooseLabel
- data ChooseH (a :: Type -> Type) b where
- data ChooseHLabel
- data Fail (a :: Type -> Type) b where
- data FailLabel
- data Fix (a :: Type -> Type) b where
- data FixLabel
- data UnliftBase (b :: Type -> Type) (f :: Type -> Type) a where
- WithRunInBase :: forall (f :: Type -> Type) (b :: Type -> Type) a. ((forall x. f x -> b x) -> b a) -> UnliftBase b f a
- type UnliftIO = UnliftBase IO
- data UnliftBaseLabel (b :: Type -> Type)
- data CC (ref :: Type -> Type) (a :: Type -> Type) b where
- data CCLabel
Documentation
data EffectOrder Source #
An order of effect.
Constructors
FirstOrder | |
HigherOrder |
Instances
Show EffectOrder Source # | |
Defined in Data.Effect Methods showsPrec :: Int -> EffectOrder -> ShowS # show :: EffectOrder -> String # showList :: [EffectOrder] -> ShowS # | |
Eq EffectOrder Source # | |
Defined in Data.Effect | |
Ord EffectOrder Source # | |
Defined in Data.Effect Methods compare :: EffectOrder -> EffectOrder -> Ordering # (<) :: EffectOrder -> EffectOrder -> Bool # (<=) :: EffectOrder -> EffectOrder -> Bool # (>) :: EffectOrder -> EffectOrder -> Bool # (>=) :: EffectOrder -> EffectOrder -> Bool # max :: EffectOrder -> EffectOrder -> EffectOrder # min :: EffectOrder -> EffectOrder -> EffectOrder # |
type family OrderOf (e :: Effect) :: EffectOrder Source #
Instances
type family OrderCase (o :: EffectOrder) (a :: k) (b :: k) :: k where ... Source #
Equations
OrderCase 'FirstOrder (a :: k) (b :: k) = a | |
OrderCase 'HigherOrder (a :: k) (b :: k) = b |
data EffectForm Source #
Constructors
Polynomial | |
Exponential |
Instances
Show EffectForm Source # | |
Defined in Data.Effect Methods showsPrec :: Int -> EffectForm -> ShowS # show :: EffectForm -> String # showList :: [EffectForm] -> ShowS # | |
Eq EffectForm Source # | |
Defined in Data.Effect | |
Ord EffectForm Source # | |
Defined in Data.Effect Methods compare :: EffectForm -> EffectForm -> Ordering # (<) :: EffectForm -> EffectForm -> Bool # (<=) :: EffectForm -> EffectForm -> Bool # (>) :: EffectForm -> EffectForm -> Bool # (>=) :: EffectForm -> EffectForm -> Bool # max :: EffectForm -> EffectForm -> EffectForm # min :: EffectForm -> EffectForm -> EffectForm # |
type family FormOf (e :: Effect) :: EffectForm Source #
Instances
type FormOf Choose Source # | |
Defined in Data.Effect | |
type FormOf ChooseH Source # | |
Defined in Data.Effect | |
type FormOf Empty Source # | |
Defined in Data.Effect | |
type FormOf Fail Source # | |
Defined in Data.Effect | |
type FormOf Fix Source # | |
Defined in Data.Effect | |
type FormOf Nop Source # | |
Defined in Data.Effect | |
type FormOf (Ask r) Source # | |
Defined in Data.Effect | |
type FormOf (CC ref) Source # | |
Defined in Data.Effect | |
type FormOf (Catch e) Source # | |
Defined in Data.Effect | |
type FormOf (Emb e) Source # | |
Defined in Data.Effect | |
type FormOf (Local r) Source # | |
Defined in Data.Effect | |
type FormOf (State s) Source # | |
Defined in Data.Effect | |
type FormOf (Tell w) Source # | |
Defined in Data.Effect | |
type FormOf (Throw e) Source # | |
Defined in Data.Effect | |
type FormOf (UnliftBase b) Source # | |
Defined in Data.Effect | |
type FormOf (WriterH w) Source # | |
Defined in Data.Effect |
type family FormCase (f :: EffectForm) (a :: k) (b :: k) :: k where ... Source #
Equations
FormCase 'Polynomial (a :: k) (b :: k) = a | |
FormCase 'Exponential (a :: k) (b :: k) = b |
type family LabelOf (e :: Effect) Source #
Instances
type LabelOf Choose Source # | |
Defined in Data.Effect | |
type LabelOf ChooseH Source # | |
Defined in Data.Effect | |
type LabelOf Empty Source # | |
Defined in Data.Effect | |
type LabelOf Fail Source # | |
Defined in Data.Effect | |
type LabelOf Fix Source # | |
Defined in Data.Effect | |
type LabelOf Nop Source # | |
Defined in Data.Effect | |
type LabelOf (Ask r) Source # | |
Defined in Data.Effect | |
type LabelOf (CC ref) Source # | |
Defined in Data.Effect | |
type LabelOf (Catch e) Source # | |
Defined in Data.Effect | |
type LabelOf (Emb e) Source # | |
Defined in Data.Effect | |
type LabelOf (Local r) Source # | |
Defined in Data.Effect | |
type LabelOf (State s) Source # | |
Defined in Data.Effect | |
type LabelOf (Tell w) Source # | |
Defined in Data.Effect | |
type LabelOf (Throw e) Source # | |
Defined in Data.Effect | |
type LabelOf (UnliftBase b) Source # | |
Defined in Data.Effect | |
type LabelOf (WriterH w) Source # | |
Defined in Data.Effect | |
type LabelOf (Tagged tag e) Source # | |
Defined in Data.Effect.Tag |
class (OrderOf e ~ 'FirstOrder, forall (f :: Type -> Type) (g :: Type -> Type) a. Coercible (e f a) (e g a)) => FirstOrder (e :: Effect) Source #
Instances
FirstOrder Choose Source # | |
Defined in Data.Effect | |
FirstOrder Empty Source # | |
Defined in Data.Effect | |
FirstOrder Fail Source # | |
Defined in Data.Effect | |
FirstOrder Nop Source # | |
Defined in Data.Effect | |
FirstOrder (Ask r) Source # | |
Defined in Data.Effect | |
FirstOrder (CC ref) Source # | |
Defined in Data.Effect | |
FirstOrder (Emb e) Source # | |
Defined in Data.Effect | |
FirstOrder (State s) Source # | |
Defined in Data.Effect | |
FirstOrder (Tell w) Source # | |
Defined in Data.Effect | |
FirstOrder (Throw e) Source # | |
Defined in Data.Effect | |
FirstOrder e => FirstOrder (Tagged tag e) Source # | |
Defined in Data.Effect.Tag |
class FormOf e ~ 'Polynomial => PolyHFunctor (e :: Effect) Source #
A higher-order polynomial functor.
Instances
PolyHFunctor Choose Source # | |
Defined in Data.Effect | |
PolyHFunctor ChooseH Source # | |
Defined in Data.Effect | |
PolyHFunctor Empty Source # | |
Defined in Data.Effect | |
PolyHFunctor Fail Source # | |
Defined in Data.Effect | |
PolyHFunctor Fix Source # | |
Defined in Data.Effect | |
PolyHFunctor Nop Source # | |
Defined in Data.Effect | |
PolyHFunctor (Ask r) Source # | |
Defined in Data.Effect | |
PolyHFunctor (CC ref) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Catch e) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Emb e) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Local r) Source # | |
Defined in Data.Effect | |
PolyHFunctor (State s) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Tell w) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Throw e) Source # | |
Defined in Data.Effect | |
PolyHFunctor (WriterH w) Source # | |
Defined in Data.Effect |
Nop Effect
data Nop (a :: Type -> Type) b Source #
A effect with no operations.
Instances
FirstOrder Nop Source # | |
Defined in Data.Effect | |
PolyHFunctor Nop Source # | |
Defined in Data.Effect | |
HFunctor Nop Source # | |
type FormOf Nop Source # | |
Defined in Data.Effect | |
type LabelOf Nop Source # | |
Defined in Data.Effect | |
type OrderOf Nop Source # | |
Defined in Data.Effect |
Embedding Effect
newtype Emb (e :: Type -> Type) (f :: Type -> Type) a Source #
Instances
FirstOrder (Emb e) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Emb e) Source # | |
Defined in Data.Effect | |
HFunctor (Emb e) Source # | |
Foldable e => Foldable (Emb e f) Source # | |
Defined in Data.Effect Methods fold :: Monoid m => Emb e f m -> m # foldMap :: Monoid m => (a -> m) -> Emb e f a -> m # foldMap' :: Monoid m => (a -> m) -> Emb e f a -> m # foldr :: (a -> b -> b) -> b -> Emb e f a -> b # foldr' :: (a -> b -> b) -> b -> Emb e f a -> b # foldl :: (b -> a -> b) -> b -> Emb e f a -> b # foldl' :: (b -> a -> b) -> b -> Emb e f a -> b # foldr1 :: (a -> a -> a) -> Emb e f a -> a # foldl1 :: (a -> a -> a) -> Emb e f a -> a # elem :: Eq a => a -> Emb e f a -> Bool # maximum :: Ord a => Emb e f a -> a # minimum :: Ord a => Emb e f a -> a # | |
Traversable e => Traversable (Emb e f) Source # | |
Applicative e => Applicative (Emb e f) Source # | |
Functor e => Functor (Emb e f) Source # | |
Monad e => Monad (Emb e f) Source # | |
type FormOf (Emb e) Source # | |
Defined in Data.Effect | |
type LabelOf (Emb e) Source # | |
Defined in Data.Effect | |
type OrderOf (Emb e) Source # | |
Defined in Data.Effect |
Reader Effects
data Ask r (a :: Type -> Type) b where Source #
An effect that holds a value of type r
in the context (environment).
Instances
FirstOrder (Ask r) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Ask r) Source # | |
Defined in Data.Effect | |
HFunctor (Ask r) Source # | |
type FormOf (Ask r) Source # | |
Defined in Data.Effect | |
type LabelOf (Ask r) Source # | |
Defined in Data.Effect | |
type OrderOf (Ask r) Source # | |
Defined in Data.Effect |
data Local r (a :: Type -> Type) b where Source #
An effect that locally modifies the value held in the environment.
Constructors
Local | Locally modifies the value held in the environment. |
Instances
PolyHFunctor (Local r) Source # | |
Defined in Data.Effect | |
HFunctor (Local r) Source # | |
type FormOf (Local r) Source # | |
Defined in Data.Effect | |
type LabelOf (Local r) Source # | |
Defined in Data.Effect | |
type OrderOf (Local r) Source # | |
Defined in Data.Effect |
data LocalLabel Source #
State Effect
data State s (a :: Type -> Type) b where Source #
An effect for holding mutable state values in the context.
Constructors
Get :: forall s (a :: Type -> Type). State s a s | Retrieves the current state value from the context. |
Put :: forall s (a :: Type -> Type). s -> State s a () | Overwrites the state value in the context. |
Instances
FirstOrder (State s) Source # | |
Defined in Data.Effect | |
PolyHFunctor (State s) Source # | |
Defined in Data.Effect | |
HFunctor (State s) Source # | |
type FormOf (State s) Source # | |
Defined in Data.Effect | |
type LabelOf (State s) Source # | |
Defined in Data.Effect | |
type OrderOf (State s) Source # | |
Defined in Data.Effect |
data StateLabel Source #
Writer Effects
data Tell w (a :: Type -> Type) b where Source #
An effect that can accumulate values monoidally in a context.
Constructors
Tell :: forall w (a :: Type -> Type). w -> Tell w a () | Accumulates new values to the cumulative value held in the context. |
Instances
FirstOrder (Tell w) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Tell w) Source # | |
Defined in Data.Effect | |
HFunctor (Tell w) Source # | |
type FormOf (Tell w) Source # | |
Defined in Data.Effect | |
type LabelOf (Tell w) Source # | |
Defined in Data.Effect | |
type OrderOf (Tell w) Source # | |
Defined in Data.Effect |
data WriterH w (a :: Type -> Type) b where Source #
An effect that performs local operations on accumulations in the context on a per-scope basis.
Constructors
Listen | Obtains the accumulated value in the scope and returns it together as a pair. |
Censor | Modifies the accumulation in the scope based on the given function. |
Instances
PolyHFunctor (WriterH w) Source # | |
Defined in Data.Effect | |
HFunctor (WriterH w) Source # | |
type FormOf (WriterH w) Source # | |
Defined in Data.Effect | |
type LabelOf (WriterH w) Source # | |
Defined in Data.Effect | |
type OrderOf (WriterH w) Source # | |
Defined in Data.Effect |
data WriterHLabel Source #
Exception Effects
data Throw e (a :: Type -> Type) b where Source #
An effect to escape from the normal control structure with an exception value of type e
in the middle of a context.
Constructors
Throw :: forall e (a :: Type -> Type) b. e -> Throw e a b | Throws an exception; that is, escapes from the normal control structure with an exception value in the middle of a context. |
Instances
FirstOrder (Throw e) Source # | |
Defined in Data.Effect | |
PolyHFunctor (Throw e) Source # | |
Defined in Data.Effect | |
HFunctor (Throw e) Source # | |
type FormOf (Throw e) Source # | |
Defined in Data.Effect | |
type LabelOf (Throw e) Source # | |
Defined in Data.Effect | |
type OrderOf (Throw e) Source # | |
Defined in Data.Effect |
data ThrowLabel Source #
data Catch e (a :: Type -> Type) b where Source #
An effect to catch exceptions.
Constructors
Catch | Catches exceptions within a scope and processes them according to the given exception handler. |
Instances
PolyHFunctor (Catch e) Source # | |
Defined in Data.Effect | |
HFunctor (Catch e) Source # | |
type FormOf (Catch e) Source # | |
Defined in Data.Effect | |
type LabelOf (Catch e) Source # | |
Defined in Data.Effect | |
type OrderOf (Catch e) Source # | |
Defined in Data.Effect |
data CatchLabel Source #
Non-Determinism Effects
data Empty (a :: Type -> Type) b where Source #
An effect that eliminates a branch by causing the current branch context of a non-deterministic computation to fail.
Constructors
Empty :: forall (a :: Type -> Type) b. Empty a b | Eliminates a branch by causing the current branch context of a non-deterministic computation to fail. |
Instances
FirstOrder Empty Source # | |
Defined in Data.Effect | |
PolyHFunctor Empty Source # | |
Defined in Data.Effect | |
HFunctor Empty Source # | |
type FormOf Empty Source # | |
Defined in Data.Effect | |
type LabelOf Empty Source # | |
Defined in Data.Effect | |
type OrderOf Empty Source # | |
Defined in Data.Effect |
data EmptyLabel Source #
data Choose (a :: Type -> Type) b where Source #
An effect that splits the computation into two branches.
Constructors
Choose :: forall (a :: Type -> Type). Choose a Bool | Splits the computation into two branches.
As a result of executing |
Instances
FirstOrder Choose Source # | |
Defined in Data.Effect | |
PolyHFunctor Choose Source # | |
Defined in Data.Effect | |
HFunctor Choose Source # | |
type FormOf Choose Source # | |
Defined in Data.Effect | |
type LabelOf Choose Source # | |
Defined in Data.Effect | |
type OrderOf Choose Source # | |
Defined in Data.Effect |
data ChooseLabel Source #
data ChooseH (a :: Type -> Type) b where Source #
An effect that executes two branches as scopes.
A higher-order version of the Choose
effect.
Constructors
ChooseH :: forall (a :: Type -> Type) b. a b -> a b -> ChooseH a b | Executes the given two scopes as branches.
Even if one fails due to the |
Instances
PolyHFunctor ChooseH Source # | |
Defined in Data.Effect | |
HFunctor ChooseH Source # | |
type FormOf ChooseH Source # | |
Defined in Data.Effect | |
type LabelOf ChooseH Source # | |
Defined in Data.Effect | |
type OrderOf ChooseH Source # | |
Defined in Data.Effect |
data ChooseHLabel Source #
Fail Effect
data Fail (a :: Type -> Type) b where Source #
Instances
FirstOrder Fail Source # | |
Defined in Data.Effect | |
PolyHFunctor Fail Source # | |
Defined in Data.Effect | |
HFunctor Fail Source # | |
type FormOf Fail Source # | |
Defined in Data.Effect | |
type LabelOf Fail Source # | |
Defined in Data.Effect | |
type OrderOf Fail Source # | |
Defined in Data.Effect |
Fix Effect
data Fix (a :: Type -> Type) b where Source #
Instances
PolyHFunctor Fix Source # | |
Defined in Data.Effect | |
HFunctor Fix Source # | |
type FormOf Fix Source # | |
Defined in Data.Effect | |
type LabelOf Fix Source # | |
Defined in Data.Effect | |
type OrderOf Fix Source # | |
Defined in Data.Effect |
Unlift Effect
data UnliftBase (b :: Type -> Type) (f :: Type -> Type) a where Source #
Constructors
WithRunInBase :: forall (f :: Type -> Type) (b :: Type -> Type) a. ((forall x. f x -> b x) -> b a) -> UnliftBase b f a |
Instances
HFunctor (UnliftBase b) Source # | |
Defined in Data.Effect Methods hfmap :: (forall x. f x -> g x) -> UnliftBase b f a -> UnliftBase b g a Source # | |
type FormOf (UnliftBase b) Source # | |
Defined in Data.Effect | |
type LabelOf (UnliftBase b) Source # | |
Defined in Data.Effect | |
type OrderOf (UnliftBase b) Source # | |
Defined in Data.Effect |
type UnliftIO = UnliftBase IO Source #
data UnliftBaseLabel (b :: Type -> Type) Source #
CallCC Effect (Sub/Jump-based)
data CC (ref :: Type -> Type) (a :: Type -> Type) b where Source #
Constructors
SubFork :: forall (ref :: Type -> Type) (a :: Type -> Type) a1. CC ref a (Either (ref a1) a1) | |
Jump :: forall (ref :: Type -> Type) a1 (a :: Type -> Type) b. ref a1 -> a1 -> CC ref a b |
Instances
FirstOrder (CC ref) Source # | |
Defined in Data.Effect | |
PolyHFunctor (CC ref) Source # | |
Defined in Data.Effect | |
HFunctor (CC ref) Source # | |
type FormOf (CC ref) Source # | |
Defined in Data.Effect | |
type LabelOf (CC ref) Source # | |
Defined in Data.Effect | |
type OrderOf (CC ref) Source # | |
Defined in Data.Effect |