effectful-core
Safe HaskellSafe-Inferred
LanguageGHC2021

Effectful.Labeled.ReturnWith

Description

Convenience functions for the Labeled ReturnWith effect.

Since: 2.7.0.0

Synopsis

Effect

data ReturnWith r :: Effect where Source #

Provide the ability to return early with a value of type r.

Constructors

ReturnWith :: r -> ReturnWith r m a 

Instances

Instances details
type DispatchOf (ReturnWith r) Source # 
Instance details

Defined in Effectful.ReturnWith.Dynamic

Handlers

runReturnWith :: forall label r es. HasCallStack => Eff (Labeled label (ReturnWith r) : es) r -> Eff es r Source #

Run a computation that can return early with a value of type r (via Effectful.ReturnWith.Static).

Operations

returnWith Source #

Arguments

:: forall label r es a. (HasCallStack, Labeled label (ReturnWith r) :> es) 
=> r

The value.

-> Eff es a 

Return early with the given value.

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)