effectful-core 2.0.0.0 → 2.1.0.0
raw patch · 6 files changed
+19/−11 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Effectful.Dispatch.Dynamic: type EffectHandler e es = forall a localEs. HasCallStack => LocalEnv localEs es " Capture of the local environment for handling local 'Eff' computations when @e@ is a higher order effect." -> e (Eff localEs) a " The effect performed in the local environment." -> Eff es a
+ Effectful.Dispatch.Dynamic: type EffectHandler e es = forall a localEs. (HasCallStack, e :> localEs) => LocalEnv localEs es " Capture of the local environment for handling local 'Eff' computations when @e@ is a higher order effect." -> e (Eff localEs) a " The effect performed in the local environment." -> Eff es a
- Effectful.Internal.Monad: type EffectHandler e es = forall a localEs. HasCallStack => LocalEnv localEs es " Capture of the local environment for handling local 'Eff' computations when @e@ is a higher order effect." -> e (Eff localEs) a " The effect performed in the local environment." -> Eff es a
+ Effectful.Internal.Monad: type EffectHandler e es = forall a localEs. (HasCallStack, e :> localEs) => LocalEnv localEs es " Capture of the local environment for handling local 'Eff' computations when @e@ is a higher order effect." -> e (Eff localEs) a " The effect performed in the local environment." -> Eff es a
Files
- CHANGELOG.md +6/−0
- effectful-core.cabal +1/−1
- src/Effectful/Error/Dynamic.hs +3/−1
- src/Effectful/Error/Static.hs +1/−1
- src/Effectful/Internal/Env.hs +7/−7
- src/Effectful/Internal/Monad.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,9 @@+# effectful-core-2.1.0.0 (2022-08-22)+* Include the `e :> localEs` constraint in the `EffectHandler` to allow more+ flexibility in handling higher order effects.+* Do not include internal stack frames in `throwError` from+ `Effectful.Error.Dynamic`.+ # effectful-core-2.0.0.0 (2022-08-12) * Make storage references in the environment immutable. * Remove `checkSizeEnv` and `forkEnv` from
effectful-core.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 build-type: Simple name: effectful-core-version: 2.0.0.0+version: 2.1.0.0 license: BSD-3-Clause license-file: LICENSE category: Control
src/Effectful/Error/Dynamic.hs view
@@ -24,6 +24,8 @@ , E.prettyCallStack ) where +import GHC.Stack (withFrozenCallStack)+ import Effectful import Effectful.Dispatch.Dynamic import qualified Effectful.Error.Static as E@@ -57,7 +59,7 @@ => e -- ^ The error. -> Eff es a-throwError = send . ThrowError+throwError e = withFrozenCallStack $ send (ThrowError e) -- | Handle an error of type @e@. catchError
src/Effectful/Error/Static.hs view
@@ -73,7 +73,7 @@ -- predictable behavior. -- -- /Hint:/ if you'd like to reproduce the transactional behavior with the--- 'Effectful.State.Static.Local.State' effect, appropriate usage of+-- t'Effectful.State.Static.Local.State' effect, appropriate usage of -- 'Control.Monad.Catch.bracketOnError' will do the trick. module Effectful.Error.Static ( -- * Effect
src/Effectful/Internal/Env.hs view
@@ -190,8 +190,8 @@ -- | Shrink the environment by one data type. ----- /Note:/ after calling this function the input environment is no longer--- usable.+-- /Note:/ after calling this function @e@ from the input environment is no+-- longer usable. unconsEnv :: Env (e : es) -> IO () unconsEnv (Env _ refs storage) = do deleteEffect storage (indexPrimArray refs 0)@@ -317,18 +317,18 @@ => Env es -> IO (Int, SmallMutableArray RealWorld Any) getLocation (Env offset refs storage) = do- let ix = offset + 2 * reifyIndex @e @es- i = indexPrimArray refs ix+ let i = offset + 2 * reifyIndex @e @es+ ref = indexPrimArray refs i+ version = indexPrimArray refs (i + 1) Storage _ _ vs es _ <- readIORef storage- let version = indexPrimArray refs (ix + 1)- storageVersion <- readPrimArray vs i+ storageVersion <- readPrimArray vs ref -- If version of the reference is different than version in the storage, it -- means that the effect in the storage is not the one that was initially -- referenced. when (version /= storageVersion) $ do error $ "version (" ++ show version ++ ") /= storageVersion (" ++ show storageVersion ++ ")"- pure (i, es)+ pure (ref, es) ---------------------------------------- -- Internal helpers
src/Effectful/Internal/Monad.hs view
@@ -373,7 +373,7 @@ -- | Type signature of the effect handler. type EffectHandler e es- = forall a localEs. HasCallStack+ = forall a localEs. (HasCallStack, e :> localEs) => LocalEnv localEs es -- ^ Capture of the local environment for handling local 'Eff' computations -- when @e@ is a higher order effect.