effectful-core
Safe HaskellSafe-Inferred
LanguageGHC2021

Effectful.Labeled.Provider

Description

Convenience functions for the Labeled Provider effect.

Since: 2.7.0.0

Synopsis

Effect

data Provider (e :: Effect) (input :: Type) (f :: Type -> Type) :: Effect where Source #

Provide a way to run a handler of e with a given input.

Note: f can be used to alter the return type of the effect handler. If that's unnecessary, use Provider_.

Constructors

ProvideWith :: input -> Eff (e : es) a -> Provider e input f (Eff es) (f a)

Run the effect handler with a given input.

Since: 2.7.0.0

Instances

Instances details
type DispatchOf (Provider e input f) Source # 
Instance details

Defined in Effectful.Provider

type DispatchOf (Provider e input f) = 'Dynamic

type Provider_ e input = Provider e input Identity Source #

A restricted variant of Provider with unchanged return type of the effect handler.

Handlers

runProvider Source #

Arguments

:: forall label e input f es a. HasCallStack 
=> (forall r. HasCallStack => input -> Eff (e : es) r -> Eff es (f r))

The effect handler.

-> Eff (Labeled label (Provider e input f) : es) a 
-> Eff es a 

Run the labeled Provider effect with a given effect handler.

runProvider_ Source #

Arguments

:: forall label e input es a. HasCallStack 
=> (forall r. HasCallStack => input -> Eff (e : es) r -> Eff es r)

The effect handler.

-> Eff (Labeled label (Provider_ e input) : es) a 
-> Eff es a 

Run the labeled Provider effect with a given effect handler that doesn't change its return type.

Operations

provide :: forall label e f es a. (HasCallStack, Labeled label (Provider e () f) :> es) => Eff (e : es) a -> Eff es (f a) Source #

Run the effect handler.

provide_ :: forall label e es a. (HasCallStack, Labeled label (Provider_ e ()) :> es) => Eff (e : es) a -> Eff es a Source #

Run the effect handler with unchanged return type.

provideWith Source #

Arguments

:: forall label e input f es a. (HasCallStack, Labeled label (Provider e input f) :> es) 
=> input

The input to the effect handler.

-> Eff (e : es) a 
-> Eff es (f a) 

Run the effect handler with a given input.

provideWith_ Source #

Arguments

:: forall label e input es a. (HasCallStack, Labeled label (Provider_ e input) :> es) 
=> input

The input to the effect handler.

-> Eff (e : es) a 
-> Eff es a 

Run the effect handler that doesn't change its return type with a given input.

Re-exports

newtype Labeled (label :: k) (e :: Effect) :: Effect where Source #

Assign a label to an effect.

Note: labeled effects are best used together with the effectful-plugin package, as it significantly improves their usability.

The constructor is for sending labeled operations of a dynamically dispatched effect to the handler:

>>> import Effectful.Dispatch.Dynamic
>>> :{
  data X :: Effect where
    X :: X m Int
  type instance DispatchOf X = Dynamic
:}
>>> :{
  runPureEff . runLabeled @"x" (interpret_ $ \X -> pure 333) $ do
    send $ Labeled @"x" X
:}
333

Constructors

Labeled :: forall label e m a. e m a -> Labeled label e m a

Since: 2.4.0.0

Instances

Instances details
type DispatchOf (Labeled label e) Source # 
Instance details

Defined in Effectful.Labeled

type DispatchOf (Labeled label e) = DispatchOf e
data StaticRep (Labeled label e) Source # 
Instance details

Defined in Effectful.Labeled

data StaticRep (Labeled label e)