data-effects-0.4.2.0: A basic framework for effect systems based on effects represented by GADTs.
Copyright(c) 2023-2025 Sayo contributors
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Safe HaskellNone
LanguageGHC2021

Data.Effect.Provider

Description

This module provides the Provider effect, like Effectful.Provider in the effectful package.

Synopsis

Documentation

data Scope (t :: k -> Type -> Type) (i :: k -> Type) (b :: k -> Type -> Type) (a :: Type -> Type) c where Source #

An effect to introduce a new local scope that provides effect context b s.

Constructors

Scope :: forall {k} (s :: k) (t :: k -> Type -> Type) (i :: k -> Type) a1 (a :: Type -> Type) (b :: k -> Type -> Type). i s -> ((forall x. a x -> b s x) -> b s a1) -> Scope t i b a (t s a1)

Introduces a new local scope that provides an effect context b s parameterized by type i s and with results wrapped in t s.

Instances

Instances details
HFunctor (Scope t i b) Source # 
Instance details

Defined in Data.Effect.Provider

Methods

hfmap :: (forall x. f x -> g x) -> Scope t i b f a -> Scope t i b g a #

type FormOf (Scope t i b) Source # 
Instance details

Defined in Data.Effect.Provider

type FormOf (Scope t i b) = 'Exponential
type LabelOf (Scope t i b) Source # 
Instance details

Defined in Data.Effect.Provider

type LabelOf (Scope t i b) = ScopeLabel t i
type OrderOf (Scope t i b) Source # 
Instance details

Defined in Data.Effect.Provider

type OrderOf (Scope t i b) = 'HigherOrder

scope :: forall {k} (s :: k) t i a b f (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Free c ff, f ~ Eff ff es, Scope t i b :> es) => i s -> ((forall x. f x -> b s x) -> b s a) -> f (t s a) Source #

Introduces a new local scope that provides an effect context b s parameterized by type i s and with results wrapped in t s.

scope' :: forall {k1} (key :: k1) {k2} (s :: k2) t i a b f (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Free c ff, f ~ Eff ff es, Has key (Scope t i b) es) => i s -> ((forall x. f x -> b s x) -> b s a) -> f (t s a) Source #

Introduces a new local scope that provides an effect context b s parameterized by type i s and with results wrapped in t s.

scope'' :: forall {k1} (tag :: k1) {k2} (s :: k2) t i a b f (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Free c ff, f ~ Eff ff es, Tagged tag (Scope t i b) :> es) => i s -> ((forall x. f x -> b s x) -> b s a) -> f (t s a) Source #

Introduces a new local scope that provides an effect context b s parameterized by type i s and with results wrapped in t s.

scope'_ :: forall {k} (s :: k) t i a b f (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Free c ff, f ~ Eff ff es, In (Scope t i b) es) => i s -> ((forall x. f x -> b s x) -> b s a) -> f (t s a) Source #

Introduces a new local scope that provides an effect context b s parameterized by type i s and with results wrapped in t s.

data ScopeLabel (t :: k -> Type -> Type) (i :: k -> Type) Source #

A type-level label to uniquely resolve the effect context carrier b from t and i.

newtype Const1 (f :: Type -> Type) (x :: k) a Source #

Constructors

Const1 

Fields

type Scoped (ff :: (Type -> Type) -> Type -> Type) (t :: k -> Type -> Type) (i :: k -> Type) (es :: [k -> Effect]) (r :: [Effect]) = Scope t i (ScopeC ff t i es r) Source #

An effect to introduce a new local scope that provides the scope-parametrized effect es.

newtype ScopeC (ff :: (Type -> Type) -> Type -> Type) (t :: k -> Type -> Type) (i :: k -> Type) (fs :: [k -> Effect]) (r :: [Effect]) (s :: k) a Source #

Constructors

ScopeC 

Fields

type Scoped_ (ff :: (Type -> Type) -> Type -> Type) (t :: k -> Type -> Type) (i :: k -> Type) (es :: [Effect]) (r :: [Effect]) = Scope t i (Const1 (ScopeC_ ff t i es r) :: k -> Type -> Type) Source #

An effect to introduce a new local scope that provides the effect es.

newtype ScopeC_ (ff :: (Type -> Type) -> Type -> Type) (t :: k -> Type -> Type) (i :: k -> Type) (es :: [Effect]) (r :: [Effect]) a Source #

Constructors

ScopeC_ 

Fields

type Provider (ff :: (Type -> Type) -> Type -> Type) (t :: Type -> Type) i (e :: [Effect]) (es :: [Effect]) = Scoped_ ff (Const1 t :: () -> Type -> Type) (Const i :: () -> Type) e es Source #

runScoped :: forall {k} t i a (es :: [k -> Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (KnownLength es, Free c ff) => (forall (s :: k) x. i s -> Eff ff (Each es s ++ (Scoped ff t i es r ': r)) x -> Eff ff (Scoped ff t i es r ': r) (t s x)) -> Eff ff (Scoped ff t i es r ': r) a -> Eff ff r a Source #

runRegionScoped :: forall {k} (b :: Type -> Type) t i a (es :: [k -> Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (WeakenExps r, UnliftBase b :> r, Emb b :> RemoveExps r, KnownLength es, Free c ff) => (forall (s :: k) x. i s -> Eff ff (Each es s ++ (Scoped ff t i es (RemoveExps r) ': r)) x -> Eff ff (Scoped ff t i es (RemoveExps r) ': r) (t s x)) -> Eff ff (Scoped ff t i es (RemoveExps r) ': r) a -> Eff ff r a Source #

scoped :: forall {k} t i (s :: k) a (es' :: [Effect]) (es :: [k -> Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Scoped ff t i es r :> es', Free c ff) => i s -> ((Eff ff es' ~> Eff ff (Each es s ++ (Scoped ff t i es r ': r))) -> Eff ff (Each es s ++ (Scoped ff t i es r ': r)) a) -> Eff ff es' (t s a) Source #

runScoped_ :: forall {k} t i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (KnownLength es, Free c ff) => (forall (p :: k) x. i p -> Eff ff (es ++ (Scoped_ ff t i es r ': r)) x -> Eff ff (Scoped_ ff t i es r ': r) (t p x)) -> Eff ff (Scoped_ ff t i es r ': r) a -> Eff ff r a Source #

runRegionScoped_ :: forall {k} (b :: Type -> Type) t i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (WeakenExps r, UnliftBase b :> r, Emb b :> RemoveExps r, KnownLength es, Free c ff) => (forall (p :: k) x. i p -> Eff ff (es ++ (Scoped_ ff t i es (RemoveExps r) ': r)) x -> Eff ff (Scoped_ ff t i es (RemoveExps r) ': r) (t p x)) -> Eff ff (Scoped_ ff t i es (RemoveExps r) ': r) a -> Eff ff r a Source #

scoped_ :: forall {k} t i (s :: k) a (es' :: [Effect]) (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Scoped_ ff t i es r :> es', Free c ff) => i s -> ((Eff ff es' ~> Eff ff (es ++ (Scoped_ ff t i es r ': r))) -> Eff ff (es ++ (Scoped_ ff t i es r ': r)) a) -> Eff ff es' (t s a) Source #

runProvider :: forall t i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. i -> Eff ff (es ++ (Provider ff t i es r ': r)) x -> Eff ff (Provider ff t i es r ': r) (t x)) -> Eff ff (Provider ff t i es r ': r) a -> Eff ff r a Source #

runRegionProvider :: forall (b :: Type -> Type) t i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (WeakenExps r, UnliftBase b :> r, Emb b :> RemoveExps r, forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. i -> Eff ff (es ++ (Provider ff t i es (RemoveExps r) ': r)) x -> Eff ff (Provider ff t i es (RemoveExps r) ': r) (t x)) -> Eff ff (Provider ff t i es (RemoveExps r) ': r) a -> Eff ff r a Source #

provide :: forall t i a (es' :: [Effect]) (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Provider ff t i es r :> es', forall (es'' :: [Effect]). Functor (Eff ff es''), Free c ff) => i -> ((Eff ff es' ~> Eff ff (es ++ (Provider ff t i es r ': r))) -> Eff ff (es ++ (Provider ff t i es r ': r)) a) -> Eff ff es' (t a) Source #

runProvider_ :: forall i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. i -> Eff ff (es ++ (Provider ff Identity i es r ': r)) x -> Eff ff (Provider ff Identity i es r ': r) x) -> Eff ff (Provider ff Identity i es r ': r) a -> Eff ff r a Source #

runRegionProvider_ :: forall (b :: Type -> Type) i a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (WeakenExps r, UnliftBase b :> r, Emb b :> RemoveExps r, forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. i -> Eff ff (es ++ (Provider ff Identity i es (RemoveExps r) ': r)) x -> Eff ff (Provider ff Identity i es (RemoveExps r) ': r) x) -> Eff ff (Provider ff Identity i es (RemoveExps r) ': r) a -> Eff ff r a Source #

provide_ :: forall i a (es' :: [Effect]) (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Provider ff Identity i es r :> es', forall (es'' :: [Effect]). Functor (Eff ff es''), Free c ff) => i -> ((Eff ff es' ~> Eff ff (es ++ (Provider ff Identity i es r ': r))) -> Eff ff (es ++ (Provider ff Identity i es r ': r)) a) -> Eff ff es' a Source #

runProvider__ :: forall a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. Eff ff (es ++ (Provider ff Identity () es r ': r)) x -> Eff ff (Provider ff Identity () es r ': r) x) -> Eff ff (Provider ff Identity () es r ': r) a -> Eff ff r a Source #

runRegionProvider__ :: forall (b :: Type -> Type) a (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (WeakenExps r, UnliftBase b :> r, Emb b :> RemoveExps r, forall (es' :: [Effect]). Functor (Eff ff es'), KnownLength es, Free c ff) => (forall x. Eff ff (es ++ (Provider ff Identity () es (RemoveExps r) ': r)) x -> Eff ff (Provider ff Identity () es (RemoveExps r) ': r) x) -> Eff ff (Provider ff Identity () es (RemoveExps r) ': r) a -> Eff ff r a Source #

provide__ :: forall a (es' :: [Effect]) (es :: [Effect]) (r :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Provider ff Identity () es r :> es', forall (es'' :: [Effect]). Functor (Eff ff es''), Free c ff) => ((Eff ff es' ~> Eff ff (es ++ (Provider ff Identity () es r ': r))) -> Eff ff (es ++ (Provider ff Identity () es r ': r)) a) -> Eff ff es' a Source #