| Copyright | (c) 2024 Sayo Koyoneda |
|---|---|
| License | MPL-2.0 (see the LICENSE file) |
| Maintainer | ymdfield@outlook.jp |
| Safe Haskell | None |
| Language | GHC2021 |
Control.Monad.Hefty.Types
Description
This module defines the Eff monad and related fundamental types and functions.
Please refer to the documentation of the top-level module.
Synopsis
- data Eff (eh :: [EffectH]) (ef :: [EffectF]) a
- type (:!!) = Eff
- type (!!) (eh :: EffectH) (ef :: EffectF) = SumToRecUnionList UnionH eh :!! SumToRecUnionList Union ef
- type ($) (f :: Type -> Type) a = f a
- type ($$) (h :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = h f
- type Interpreter (e :: Type -> Type) (m :: Type -> Type) ans = forall x. e x -> (x -> m ans) -> m ans
- type Elaborator (e :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) ans = Interpreter (e m) m ans
- type (~~>) (e :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = e f ~> f
- send :: forall (e :: EffectF) (ef :: [EffectF]) (eh :: [EffectH]). e <| ef => e ~> Eff eh ef
- sendH :: forall (e :: EffectH) (eh :: [EffectH]) (ef :: [EffectF]). e <<| eh => e (Eff eh ef) ~> Eff eh ef
- send0 :: forall e (eh :: [EffectH]) (ef :: [Type -> Type]) x. e x -> Eff eh (e ': ef) x
- send0H :: forall e (eh :: [(Type -> Type) -> Type -> Type]) (ef :: [EffectF]) x. e (Eff (e ': eh) ef) x -> Eff (e ': eh) ef x
- sendN :: forall (i :: Nat) (ef :: [Type -> Type]) (eh :: [EffectH]). KnownNat i => ElemAt i ef ~> Eff eh ef
- sendNH :: forall (i :: Nat) (eh :: [(Type -> Type) -> Type -> Type]) (ef :: [EffectF]). KnownNat i => ElemAt i eh (Eff eh ef) ~> Eff eh ef
- sendUnion :: forall (ef :: [EffectF]) a (eh :: [EffectH]). Union ef a -> Eff eh ef a
- sendUnionBy :: forall a (eh :: [EffectH]) (ef :: [EffectF]) ans. (a -> Eff eh ef ans) -> Union ef a -> Eff eh ef ans
- sendUnionH :: forall (eh :: [EffectH]) (ef :: [EffectF]) a. UnionH eh (Eff eh ef) a -> Eff eh ef a
- sendUnionHBy :: forall a (eh :: [EffectH]) (ef :: [EffectF]) ans. (a -> Eff eh ef ans) -> UnionH eh (Eff eh ef) a -> Eff eh ef ans
- data ReaderKey
- data WriterKey
- data StateKey
- data ErrorKey
Documentation
data Eff (eh :: [EffectH]) (ef :: [EffectF]) a Source #
The Eff monad represents computations with effects.
It supports higher-order effects eh and first-order effects ef.
Constructors
| Val a | A pure value. |
| Op | An effectful operation, which can be either a higher-order effect or a first-order effect. |
Instances
type (:!!) = Eff infixr 4 Source #
Type-level infix operator for Eff.
Allows writing eh :!! ef instead of Eff eh ef.
type (!!) (eh :: EffectH) (ef :: EffectF) = SumToRecUnionList UnionH eh :!! SumToRecUnionList Union ef infixr 5 Source #
type ($$) (h :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = h f infixr 4 Source #
Type-level infix applcation for higher-order functors.
type Interpreter (e :: Type -> Type) (m :: Type -> Type) ans = forall x. e x -> (x -> m ans) -> m ans Source #
Type alias for an interpreter function.
Interpreter e m ans transforms an effect e into a computation in m where the result type (answer type) is ans.
type Elaborator (e :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) ans = Interpreter (e m) m ans Source #
Type alias for an elaborator function.
An Elaborator is an interpreter for higher-order effects.
type (~~>) (e :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = e f ~> f infix 2 Source #
Type alias for a natural transformation style elaborator.
send :: forall (e :: EffectF) (ef :: [EffectF]) (eh :: [EffectH]). e <| ef => e ~> Eff eh ef Source #
Send a first-order effect e to the Eff carrier.
sendH :: forall (e :: EffectH) (eh :: [EffectH]) (ef :: [EffectF]). e <<| eh => e (Eff eh ef) ~> Eff eh ef Source #
Send a higher-order effect e to the Eff carrier.
send0 :: forall e (eh :: [EffectH]) (ef :: [Type -> Type]) x. e x -> Eff eh (e ': ef) x Source #
Send the first-order effect e at the head of the list to the Eff carrier.
send0H :: forall e (eh :: [(Type -> Type) -> Type -> Type]) (ef :: [EffectF]) x. e (Eff (e ': eh) ef) x -> Eff (e ': eh) ef x Source #
Send the higher-order effect e at the head of the list to the Eff carrier.
sendN :: forall (i :: Nat) (ef :: [Type -> Type]) (eh :: [EffectH]). KnownNat i => ElemAt i ef ~> Eff eh ef Source #
Send the i-th first-order effect in the list to the Eff carrier.
sendNH :: forall (i :: Nat) (eh :: [(Type -> Type) -> Type -> Type]) (ef :: [EffectF]). KnownNat i => ElemAt i eh (Eff eh ef) ~> Eff eh ef Source #
Send the i-th higher-order effect in the list to the Eff carrier.
sendUnion :: forall (ef :: [EffectF]) a (eh :: [EffectH]). Union ef a -> Eff eh ef a Source #
Send an open union of all first-order effects to the Eff carrier.
sendUnionBy :: forall a (eh :: [EffectH]) (ef :: [EffectF]) ans. (a -> Eff eh ef ans) -> Union ef a -> Eff eh ef ans Source #
Send an open union of all first-order effects, along with its continuation, to the Eff carrier.
sendUnionH :: forall (eh :: [EffectH]) (ef :: [EffectF]) a. UnionH eh (Eff eh ef) a -> Eff eh ef a Source #
Send an open union of all higher-order effects to the Eff carrier.
sendUnionHBy :: forall a (eh :: [EffectH]) (ef :: [EffectF]) ans. (a -> Eff eh ef ans) -> UnionH eh (Eff eh ef) a -> Eff eh ef ans Source #
Send an open union of all higher-order effects, along with its continuation, to the Eff carrier.
A key to be attached to the effect targeted by the MonadReader instance.
Since MonadReader has a functional dependency on r, this is needed to uniquely specify r.
A key to be attached to the effect targeted by the MonadWriter instance.
Since MonadWriter has a functional dependency on w, this is needed to uniquely specify w.
A key to be attached to the effect targeted by the MonadState instance.
Since MonadState has a functional dependency on s, this is needed to uniquely specify s.
A key to be attached to the effect targeted by the MonadError instance.
Since MonadError has a functional dependency on e, this is needed to uniquely specify e.