effectful-core
Safe HaskellSafe-Inferred
LanguageGHC2021

Effectful.Labeled.Input

Description

Convenience functions for the Labeled Input effect.

Since: 2.7.0.0

Synopsis

Effect

data Input i :: Effect Source #

Provide access to values of type i.

Instances

Instances details
type DispatchOf (Input i) Source # 
Instance details

Defined in Effectful.Input.Dynamic

Handlers

runInput Source #

Arguments

:: forall label i es a. HasCallStack 
=> i

The input value.

-> Eff (Labeled label (Input i) : es) a 
-> Eff es a 

Run the Input effect with the given value.

runInputAction Source #

Arguments

:: forall label i es a. HasCallStack 
=> (HasCallStack => Eff es i)

The action for input generation.

-> Eff (Labeled label (Input i) : es) a 
-> Eff es a 

Run the Input effect with the given action that supplies values.

Operations

input :: forall label i es. (HasCallStack, Labeled label (Input i) :> es) => Eff es i Source #

Fetch the value.

inputs Source #

Arguments

:: forall label i es a. (HasCallStack, Labeled label (Input i) :> es) 
=> (i -> a)

The function to apply to the value.

-> Eff es a 

Fetch the result of applying a function to the value.

inputs f ≡ f <$> 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)