data-effects-0.3.0.1: A basic framework for effect systems based on effects represented by GADTs.
Copyright(c) 2023-2024 Sayo Koyoneda
LicenseMPL-2.0 (see the file LICENSE)
Maintainer[email protected]
Safe HaskellNone
LanguageGHC2021

Data.Effect.Provider

Description

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

Synopsis

Documentation

data Provider' (ctx :: k -> Type -> Type) (i :: k -> Type) (b :: k -> Type -> Type) (f :: Type -> Type) a where Source #

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

Constructors

Provide :: forall {k} (i :: k -> Type) (p :: k) (f :: Type -> Type) (b :: k -> Type -> Type) a1 (ctx :: k -> Type -> Type). i p -> ((forall x. f x -> b p x) -> b p a1) -> Provider' ctx i b f (ctx p a1)

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

Instances

Instances details
() => HFunctor (Provider' ctx i b) Source # 
Instance details

Defined in Data.Effect.Provider

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> Provider' ctx i b f :-> Provider' ctx i b g #

provide :: forall {k} i (p :: k) b a ctx f. SendHOE (Provider' ctx i b) f => i p -> ((forall x. f x -> b p x) -> b p a) -> f (ctx p a) Source #

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

provide' :: forall {k1} (tag :: k1) {k2} i (p :: k2) b a ctx f. SendHOE (TagH (Provider' ctx i b) tag) f => i p -> ((forall x. f x -> b p x) -> b p a) -> f (ctx p a) Source #

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

provide'' :: forall {k1} (key :: k1) {k2} i (p :: k2) b a ctx f. SendHOEBy key (Provider' ctx i b) f => i p -> ((forall x. f x -> b p x) -> b p a) -> f (ctx p a) Source #

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

data ProviderKey (ctx :: k) (i :: k1) Source #

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

type Provider (ctx :: k -> Type -> Type) (i :: k -> Type) (b :: k -> Type -> Type) = ProviderKey ctx i ##> Provider' ctx i b Source #

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

type Provider_ i (b :: Type -> Type) = Provider (Const1 Identity :: () -> Type -> Type) (Const i :: () -> Type) (Const1 b :: () -> Type -> Type) Source #

An effect to introduce a new local scope that provides effect context b. A version of Provider where the result is not wrapped in a specific container.

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

Constructors

Const1 

Fields

newtype Const2 (ff :: k -> k1 -> Type) (x :: k2) (f :: k) (a :: k1) Source #

Constructors

Const2 

Fields

Instances

Instances details
HFunctor ff => HFunctor (Const2 ff x) Source # 
Instance details

Defined in Data.Effect.Provider

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> Const2 ff x f :-> Const2 ff x g #

(.!) :: forall {k} i f a b. (SendHOEBy (ProviderKey (Const1 Identity :: () -> Type -> Type) (Const i :: () -> Type)) (Provider' (Const1 Identity :: k -> Type -> Type) (Const i :: k -> Type) (Const1 b :: k -> Type -> Type)) f, Functor f) => i -> ((f ~> b) -> b a) -> f a infix 2 Source #

A operator to introduce a new local scope that provides effect context b. A version of ..! where the result is not wrapped in a specific container.

(..!) :: forall {k} ctx i (p :: k) f a b. SendHOEBy (ProviderKey ctx i) (Provider' ctx i b) f => i p -> ((f ~> b p) -> b p a) -> f (ctx p a) infix 2 Source #

A operator to introduce a new local scope that provides effect context b p.