effectful-core
Safe HaskellSafe-Inferred
LanguageGHC2021

Effectful.Labeled.Provider.List

Description

Convenience functions for the Labeled ProviderList effect.

Since: 2.7.0.0

Synopsis

Effect

data ProviderList (providedEs :: [Effect]) (input :: Type) (f :: Type -> Type) :: Effect where Source #

Provide a way to run a handler of multiple providedEs with a given input.

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

Constructors

ProvideListWith :: forall providedEs input f es a. input -> Eff (providedEs ++ es) a -> ProviderList providedEs input f (Eff es) (f a)

Run the effect handlers with a given input.

Since: 2.7.0.0

Instances

Instances details
type DispatchOf (ProviderList providedEs input f) Source # 
Instance details

Defined in Effectful.Provider.List

type DispatchOf (ProviderList providedEs input f) = 'Dynamic

type ProviderList_ providedEs input = ProviderList providedEs input Identity Source #

A restricted variant of ProviderList with unchanged return type of the handler.

Handlers

runProviderList Source #

Arguments

:: forall label providedEs input f es a. (HasCallStack, KnownSubset providedEs (providedEs ++ es)) 
=> (forall r. HasCallStack => input -> Eff (providedEs ++ es) r -> Eff es (f r))

The handler.

-> Eff (Labeled label (ProviderList providedEs input f) : es) a 
-> Eff es a 

Run the labeled ProviderList effect with a given handler.

runProviderList_ Source #

Arguments

:: forall label providedEs input es a. (HasCallStack, KnownSubset providedEs (providedEs ++ es)) 
=> (forall r. HasCallStack => input -> Eff (providedEs ++ es) r -> Eff es r)

The handler.

-> Eff (Labeled label (ProviderList_ providedEs input) : es) a 
-> Eff es a 

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

Operations

provideList :: forall label providedEs f es a. (HasCallStack, Labeled label (ProviderList providedEs () f) :> es) => Eff (providedEs ++ es) a -> Eff es (f a) Source #

Run the handler.

provideList_ :: forall label providedEs es a. (HasCallStack, Labeled label (ProviderList_ providedEs ()) :> es) => Eff (providedEs ++ es) a -> Eff es a Source #

Run the handler with unchanged return type.

provideListWith Source #

Arguments

:: forall label providedEs input f es a. (HasCallStack, Labeled label (ProviderList providedEs input f) :> es) 
=> input

The input to the handler.

-> Eff (providedEs ++ es) a 
-> Eff es (f a) 

Run the handler with a given input.

provideListWith_ Source #

Arguments

:: forall label providedEs input es a. (HasCallStack, Labeled label (ProviderList_ providedEs input) :> es) 
=> input

The input to the handler.

-> Eff (providedEs ++ es) a 
-> Eff es a 

Run the 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)

type family (xs :: [Effect]) ++ (ys :: [Effect]) :: [Effect] where ... infixr 5 Source #

Append two type-level lists together.

Equations

'[] ++ ys = ys 
(x : xs) ++ ys = x : (xs ++ ys) 

class Subset subEs es => KnownSubset (subEs :: [Effect]) (es :: [Effect]) Source #

Provide evidence that subEs is a known subset of es.

Instances

Instances details
KnownSubset ('[] :: [Effect]) es Source # 
Instance details

Defined in Effectful.Internal.Effect

(e :> es, KnownSubset subEs es) => KnownSubset (e ': subEs) es Source # 
Instance details

Defined in Effectful.Internal.Effect