diff --git a/effectful-core/CHANGELOG.md b/effectful-core/CHANGELOG.md index 0ab8843..a7690ec 100644 --- a/effectful-core/CHANGELOG.md +++ b/effectful-core/CHANGELOG.md @@ -1,4 +1,6 @@ # effectful-core-2.4.0.0 (????-??-??) +* Add `handleWith` (`interpret` with flipped arguments) to + `Effectful.Dispatch.Dynamic`. * Add utility functions for handling first order effects to `Effectful.Dispatch.Dynamic`. diff --git a/effectful-core/src/Effectful/Dispatch/Dynamic.hs b/effectful-core/src/Effectful/Dispatch/Dynamic.hs index 753f5c8..add1be7 100644 --- a/effectful-core/src/Effectful/Dispatch/Dynamic.hs +++ b/effectful-core/src/Effectful/Dispatch/Dynamic.hs @@ -26,6 +26,7 @@ module Effectful.Dispatch.Dynamic , reinterpret , interpose , impose + , handleWith -- ** Handling local 'Eff' computations , LocalEnv @@ -59,6 +60,7 @@ module Effectful.Dispatch.Dynamic , reinterpret_ , interpose_ , impose_ + , handleWith_ -- * Re-exports , HasCallStack @@ -533,6 +535,17 @@ impose runHandlerEs handler m = unsafeEff $ \es -> do where mkHandler es = Handler es (let ?callStack = thawCallStack ?callStack in handler) +-- | 'interpret' with flipped arguments. +-- +-- @since 2.4.0.0 +handleWith + :: DispatchOf e ~ Dynamic + => Eff (e : es) a + -> EffectHandler e es + -- ^ The effect handler. + -> Eff es a +handleWith m handler = interpret handler m + ---------------------------------------- -- First order effects @@ -593,6 +606,17 @@ impose_ -> Eff es b impose_ runHandlerEs handler = impose runHandlerEs (const handler) +-- | 'handleWith' for first order effects. +-- +-- @since 2.4.0.0 +handleWith_ + :: DispatchOf e ~ Dynamic + => Eff (e : es) a + -> EffectHandler_ e es + -- ^ The effect handler. + -> Eff es a +handleWith_ m handler = interpret_ handler m + ---------------------------------------- -- Unlifts diff --git a/effectful/CHANGELOG.md b/effectful/CHANGELOG.md index 0100331..be4326a 100644 --- a/effectful/CHANGELOG.md +++ b/effectful/CHANGELOG.md @@ -1,4 +1,6 @@ # effectful-2.4.0.0 (????-??-??) +* Add `handleWith` (`interpret` with flipped arguments) to + `Effectful.Dispatch.Dynamic`. * Add utility functions for handling first order effects to `Effectful.Dispatch.Dynamic`.