data-effects-core-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

Control.Effect

Description

 
Synopsis

Documentation

newtype Eff (ff :: (Type -> Type) -> Type -> Type) (es :: [Effect]) a Source #

Constructors

Eff 

Fields

Instances

Instances details
(FindByLabel AskLabel (Ask r) es, Local r :> es, FindByLabel TellLabel (Tell w) es, WriterH w :> es, FindByLabel StateLabel (State s) es, Monoid w, Monad (Eff ff es), Free c ff) => MonadRWS r w s (Eff ff es) Source # 
Instance details

Defined in Control.Effect

(FindByLabel ThrowLabel (Throw e) es, Catch e :> es, Monad (Eff ff es), Free c ff) => MonadError e (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

throwError :: e -> Eff ff es a #

catchError :: Eff ff es a -> (e -> Eff ff es a) -> Eff ff es a #

(FindByLabel AskLabel (Ask r) es, Local r :> es, Monad (Eff ff es), Free c ff) => MonadReader r (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

ask :: Eff ff es r #

local :: (r -> r) -> Eff ff es a -> Eff ff es a #

reader :: (r -> a) -> Eff ff es a #

(FindByLabel StateLabel (State s) es, Monad (Eff ff es), Free c ff) => MonadState s (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

get :: Eff ff es s #

put :: s -> Eff ff es () #

state :: (s -> (a, s)) -> Eff ff es a #

(FindByLabel TellLabel (Tell w) es, WriterH w :> es, Monoid w, Monad (Eff ff es), Free c ff) => MonadWriter w (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

writer :: (a, w) -> Eff ff es a #

tell :: w -> Eff ff es () #

listen :: Eff ff es a -> Eff ff es (a, w) #

pass :: Eff ff es (a, w -> w) -> Eff ff es a #

(Fail :> es, Monad (Eff ff es), Free c ff) => MonadFail (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

fail :: String -> Eff ff es a #

(Fix :> es, Monad (Eff ff es), Free c ff) => MonadFix (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

mfix :: (a -> Eff ff es a) -> Eff ff es a #

(Emb IO :> es, Monad (Eff ff es), Free c ff) => MonadIO (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

liftIO :: IO a -> Eff ff es a #

(Empty :> es, ChooseH :> es, Applicative (Eff ff es), Free c ff) => Alternative (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

empty :: Eff ff es a #

(<|>) :: Eff ff es a -> Eff ff es a -> Eff ff es a #

some :: Eff ff es a -> Eff ff es [a] #

many :: Eff ff es a -> Eff ff es [a] #

(forall (r :: Type -> Type). Applicative (ff r)) => Applicative (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

pure :: a -> Eff ff es a #

(<*>) :: Eff ff es (a -> b) -> Eff ff es a -> Eff ff es b #

liftA2 :: (a -> b -> c) -> Eff ff es a -> Eff ff es b -> Eff ff es c #

(*>) :: Eff ff es a -> Eff ff es b -> Eff ff es b #

(<*) :: Eff ff es a -> Eff ff es b -> Eff ff es a #

(forall (f :: Type -> Type). Functor (ff f)) => Functor (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

fmap :: (a -> b) -> Eff ff es a -> Eff ff es b #

(<$) :: a -> Eff ff es b -> Eff ff es a #

(forall (r :: Type -> Type). Monad (ff r)) => Monad (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

(>>=) :: Eff ff es a -> (a -> Eff ff es b) -> Eff ff es b #

(>>) :: Eff ff es a -> Eff ff es b -> Eff ff es b #

return :: a -> Eff ff es a #

(Empty :> es, ChooseH :> es, Monad (Eff ff es), Free c ff) => MonadPlus (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

mzero :: Eff ff es a #

mplus :: Eff ff es a -> Eff ff es a -> Eff ff es a #

(CC ref :> es, Monad (Eff ff es), Free c ff) => MonadCont (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

callCC :: ((a -> Eff ff es b) -> Eff ff es a) -> Eff ff es a #

(UnliftIO :> es, Emb IO :> es, Monad (Eff ff es), Free c ff) => MonadUnliftIO (Eff ff es) Source # 
Instance details

Defined in Control.Effect

Methods

withRunInIO :: ((forall a. Eff ff es a -> IO a) -> IO b) -> Eff ff es b #

perform :: forall e (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (e :> es, Free c ff) => e (Eff ff es) a -> Eff ff es a Source #

perform' :: forall {k} (key :: k) e (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (Has key e es, Free c ff) => e (Eff ff es) a -> Eff ff es a Source #

perform'' :: forall {k} (tag :: k) e (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). ((e # tag) :> es, Free c ff) => e (Eff ff es) a -> Eff ff es a Source #

send :: forall e (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (In e es, Free c ff) => e (Eff ff es) a -> Eff ff es a Source #

sendAt :: forall (i :: Nat) (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (KnownIndex i es, Free c ff) => At i es (Eff ff es) a -> Eff ff es a Source #

sendFor :: forall e (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (KnownOrder e, Free c ff) => Membership e es -> e (Eff ff es) a -> Eff ff es a Source #

emb :: forall f (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) a (c :: (Type -> Type) -> Constraint). (Emb f :> es, Free c ff) => f a -> Eff ff es a Source #

type (~>) (f :: Type -> Type) (g :: Type -> Type) = forall x. f x -> g x infixr 2 Source #

A natural transformation.

type (~~>) (e :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = e f ~> f infix 2 Source #

type ($) (f :: Type -> Type) a = f a infixr 3 Source #

Type-level infix applcation for functors.

type ($$) (h :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) = h f infixr 4 Source #

Type-level infix applcation for higher-order functors.

pass :: forall w a (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (Tell w :> es, WriterH w :> es, Monad (Eff ff es), Free c ff) => Eff ff es (w -> w, a) -> Eff ff es a Source #

For a given scope, uses the function (the first component of the pair returned by that scope) to modify the accumulated value of that scope, and then accumulates the result into the current outer scope.

pass m = do
    (w, (f, a)) <- listen m
    tell $ f w
    pure a

sub :: forall ref a b (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (CC ref :> es, Monad (Eff ff es), Free c ff) => (ref a -> Eff ff es b) -> (a -> Eff ff es b) -> Eff ff es b Source #

callCC_ :: forall (ref :: Type -> Type) a b (es :: [Effect]) (ff :: (Type -> Type) -> Type -> Type) (c :: (Type -> Type) -> Constraint). (CC ref :> es, Monad (Eff ff es), Free c ff) => ((a -> Eff ff es b) -> Eff ff es a) -> Eff ff es a Source #

class (forall (f :: Type -> Type). c (ff f)) => Free (c :: (Type -> Type) -> Constraint) (ff :: (Type -> Type) -> Type -> Type) | ff -> c where Source #

Minimal complete definition

liftFree, (runFree | retract, hoist)

Methods

liftFree :: f a -> ff f a Source #

runFree :: c g => (forall x. f x -> g x) -> ff f a -> g a Source #

retract :: c f => ff f a -> f a Source #

hoist :: (forall x. f x -> g x) -> ff f a -> ff g a Source #

default hoist :: c (ff g) => (forall x. f x -> g x) -> ff f a -> ff g a Source #

Instances

Instances details
Free Alternative Alt Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Alt f a Source #

runFree :: Alternative g => (forall x. f x -> g x) -> Alt f a -> g a Source #

retract :: Alternative f => Alt f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Alt f a -> Alt g a Source #

Free Alternative Alt Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Alt f a Source #

runFree :: Alternative g => (forall x. f x -> g x) -> Alt f a -> g a Source #

retract :: Alternative f => Alt f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Alt f a -> Alt g a Source #

Free Applicative Ap Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Ap f a Source #

runFree :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a Source #

retract :: Applicative f => Ap f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Ap f a -> Ap g a Source #

Free Applicative Ap Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Ap f a Source #

runFree :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a Source #

retract :: Applicative f => Ap f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Ap f a -> Ap g a Source #

Free Applicative Ap Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Ap f a Source #

runFree :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a Source #

retract :: Applicative f => Ap f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Ap f a -> Ap g a Source #

Free Functor Coyoneda Source # 
Instance details

Defined in Control.Effect

Methods

liftFree :: f a -> Coyoneda f a Source #

runFree :: Functor g => (forall x. f x -> g x) -> Coyoneda f a -> g a Source #

retract :: Functor f => Coyoneda f a -> f a Source #

hoist :: (forall x. f x -> g x) -> Coyoneda f a -> Coyoneda g a Source #

convertEff :: forall (ff :: (Type -> Type) -> Type -> Type) (gg :: (Type -> Type) -> Type -> Type) (es :: [Effect]) a (c :: (Type -> Type) -> Constraint) (c' :: (Type -> Type) -> Constraint). (Free c ff, Free c' gg, forall (r :: Type -> Type). c (gg r)) => Eff ff es a -> Eff gg es a Source #

convertFree :: forall (c :: (Type -> Type) -> Constraint) ff (c' :: (Type -> Type) -> Constraint) gg (r :: Type -> Type) a. (Free c ff, Free c' gg, c (gg r)) => ff r a -> gg r a Source #