| Copyright | (c) 2023-2024 Sayo contributors |
|---|---|
| License | MPL-2.0 (see the file LICENSE) |
| Maintainer | ymdfield@outlook.jp |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Data.Effect
Description
Synopsis
- type Effect = (Type -> Type) -> Type -> Type
- data EffectOrder
- type family OrderOf (e :: Effect) :: EffectOrder
- type family OrderCase (e :: EffectOrder) a b where ...
- type family LabelOf (e :: Effect)
- class (OrderOf e ~ 'FirstOrder, forall f g a. Coercible (e f a) (e g a)) => FirstOrder (e :: Effect)
- data Nop :: Effect
- data NopLabel
- newtype Emb e (f :: Type -> Type) (a :: Type) = Emb {
- getEmb :: e a
- data EmbLabel (e :: Type -> Type)
- newtype Unemb e a = Unemb {
- getUnemb :: forall f. e f a
- data Ask r :: Effect where
- data AskLabel
- data Local r :: Effect where
- data LocalLabel
- data State s :: Effect where
- data StateLabel
- data Tell w :: Effect where
- data TellLabel
- data WriterH w :: Effect where
- data WriterHLabel
- data Throw e :: Effect where
- data ThrowLabel
- data Catch e :: Effect where
- data CatchLabel
- data Empty :: Effect where
- data EmptyLabel
- data Choose :: Effect where
- data ChooseLabel
- data ChooseH :: Effect where
- data ChooseHLabel
- data Fail :: Effect where
- data FailLabel
- data Fix :: Effect where
- data FixLabel
- data UnliftBase b f (a :: Type) where
- WithRunInBase :: ((forall x. f x -> b x) -> b a) -> UnliftBase b f a
- type UnliftIO = UnliftBase IO
- data UnliftBaseLabel (b :: Type -> Type)
- data CC ref :: Effect 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 (e :: EffectOrder) a b where ... Source #
Equations
| OrderCase 'FirstOrder a b = a | |
| OrderCase 'HigherOrder a b = 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 w) 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 g 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 | |
Nop Effect
A effect with no operations.
Instances
| FirstOrder Nop Source # | |
Defined in Data.Effect | |
| HFunctor Nop Source # | |
| type LabelOf Nop Source # | |
Defined in Data.Effect | |
| type OrderOf Nop Source # | |
Defined in Data.Effect | |
Embedding Effect
newtype Emb e (f :: Type -> Type) (a :: Type) Source #
Instances
| FirstOrder (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 LabelOf (Emb e) Source # | |
Defined in Data.Effect | |
| type OrderOf (Emb e) Source # | |
Defined in Data.Effect | |
Reader Effects
data Ask r :: Effect where Source #
An effect that holds a value of type r in the context (environment).
Instances
| FirstOrder (Ask r) Source # | |
Defined in Data.Effect | |
| HFunctor (Ask r) Source # | |
| type LabelOf (Ask r) Source # | |
Defined in Data.Effect | |
| type OrderOf (Ask r) Source # | |
Defined in Data.Effect | |
data Local r :: Effect where Source #
An effect that locally modifies the value held in the environment.
Constructors
| Local | Locally modifies the value held in the environment. |
Fields
| |
data LocalLabel Source #
State Effect
data State s :: Effect where Source #
An effect for holding mutable state values in the context.
Constructors
| Get :: State s f s | Retrieves the current state value from the context. |
| Put :: s -> State s f () | Overwrites the state value in the context. |
Instances
| FirstOrder (State s) Source # | |
Defined in Data.Effect | |
| HFunctor (State s) Source # | |
| 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 :: Effect where Source #
An effect that can accumulate values monoidally in a context.
Constructors
| Tell :: w -> Tell w f () | Accumulates new values to the cumulative value held in the context. |
Instances
| FirstOrder (Tell w) Source # | |
Defined in Data.Effect | |
| HFunctor (Tell w) Source # | |
| type LabelOf (Tell w) Source # | |
Defined in Data.Effect | |
| type OrderOf (Tell w) Source # | |
Defined in Data.Effect | |
data WriterH w :: Effect 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. |
Fields
| |
| Censor | Modifies the accumulation in the scope based on the given function. |
Fields
| |
data WriterHLabel Source #
Exception Effects
data Throw e :: Effect 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 :: e -> Throw e f a | 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 | |
| HFunctor (Throw e) Source # | |
| type LabelOf (Throw e) Source # | |
Defined in Data.Effect | |
| type OrderOf (Throw e) Source # | |
Defined in Data.Effect | |
data ThrowLabel Source #
data Catch e :: Effect where Source #
An effect to catch exceptions.
Constructors
| Catch | Catches exceptions within a scope and processes them according to the given exception handler. |
Fields
| |
data CatchLabel Source #
Non-Determinism Effects
data Empty :: Effect where Source #
An effect that eliminates a branch by causing the current branch context of a non-deterministic computation to fail.
Constructors
| Empty :: Empty f a | Eliminates a branch by causing the current branch context of a non-deterministic computation to fail. |
Instances
| FirstOrder Empty Source # | |
Defined in Data.Effect | |
| HFunctor Empty Source # | |
| type LabelOf Empty Source # | |
Defined in Data.Effect | |
| type OrderOf Empty Source # | |
Defined in Data.Effect | |
data EmptyLabel Source #
data Choose :: Effect where Source #
An effect that splits the computation into two branches.
Constructors
| Choose :: Choose f Bool | Splits the computation into two branches.
As a result of executing |
Instances
| FirstOrder Choose Source # | |
Defined in Data.Effect | |
| HFunctor Choose Source # | |
| type LabelOf Choose Source # | |
Defined in Data.Effect | |
| type OrderOf Choose Source # | |
Defined in Data.Effect | |
data ChooseLabel Source #
data ChooseH :: Effect where Source #
An effect that executes two branches as scopes.
A higher-order version of the Choose effect.
Constructors
| ChooseH :: f a -> f a -> ChooseH f a | Executes the given two scopes as branches.
Even if one fails due to the |
data ChooseHLabel Source #
Fail Effect
data Fail :: Effect where Source #
Instances
| FirstOrder Fail Source # | |
Defined in Data.Effect | |
| HFunctor Fail Source # | |
| type LabelOf Fail Source # | |
Defined in Data.Effect | |
| type OrderOf Fail Source # | |
Defined in Data.Effect | |
Fix Effect
Unlift Effect
data UnliftBase b f (a :: Type) where Source #
Constructors
| WithRunInBase :: ((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 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 #