polysemy-zoo 0.4.0.0 → 0.4.0.1
raw patch · 6 files changed
+30/−15 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Polysemy.Floodgate: hold :: forall r_avmO. MemberWithError Floodgate r_avmO => Sem r_avmO () -> Sem r_avmO ()
+ Polysemy.Floodgate: hold :: forall r_avts. MemberWithError Floodgate r_avts => Sem r_avts () -> Sem r_avts ()
- Polysemy.Floodgate: release :: forall r_avmQ. MemberWithError Floodgate r_avmQ => Sem r_avmQ ()
+ Polysemy.Floodgate: release :: forall r_avtu. MemberWithError Floodgate r_avtu => Sem r_avtu ()
- Polysemy.KVStore: lookupKV :: forall k_aCFc v_aCFd r_aCHa. MemberWithError (KVStore k_aCFc v_aCFd) r_aCHa => k_aCFc -> Sem r_aCHa (Maybe v_aCFd)
+ Polysemy.KVStore: lookupKV :: forall k_aCLQ v_aCLR r_aCNO. MemberWithError (KVStore k_aCLQ v_aCLR) r_aCNO => k_aCLQ -> Sem r_aCNO (Maybe v_aCLR)
- Polysemy.KVStore: updateKV :: forall k_aCFc v_aCFd r_aCHc. MemberWithError (KVStore k_aCFc v_aCFd) r_aCHc => k_aCFc -> Maybe v_aCFd -> Sem r_aCHc ()
+ Polysemy.KVStore: updateKV :: forall k_aCLQ v_aCLR r_aCNQ. MemberWithError (KVStore k_aCLQ v_aCLR) r_aCNQ => k_aCLQ -> Maybe v_aCLR -> Sem r_aCNQ ()
- Polysemy.Random: random :: forall r_ax9l a_ax7A. (MemberWithError Random r_ax9l, Random a_ax7A) => Sem r_ax9l a_ax7A
+ Polysemy.Random: random :: forall r_axfZ a_axee. (MemberWithError Random r_axfZ, Random a_axee) => Sem r_axfZ a_axee
- Polysemy.Random: randomR :: forall r_ax9m a_ax7A. (MemberWithError Random r_ax9m, Random a_ax7A) => (a_ax7A, a_ax7A) -> Sem r_ax9m a_ax7A
+ Polysemy.Random: randomR :: forall r_axg0 a_axee. (MemberWithError Random r_axg0, Random a_axee) => (a_axee, a_axee) -> Sem r_axg0 a_axee
- Polysemy.SetStore: addS :: forall k_aDVm v_aDVn r_aDYm. MemberWithError (SetStore k_aDVm v_aDVn) r_aDYm => k_aDVm -> v_aDVn -> Sem r_aDYm ()
+ Polysemy.SetStore: addS :: forall k_aE20 v_aE21 r_aE50. MemberWithError (SetStore k_aE20 v_aE21) r_aE50 => k_aE20 -> v_aE21 -> Sem r_aE50 ()
- Polysemy.SetStore: delS :: forall k_aDVm v_aDVn r_aDYp. MemberWithError (SetStore k_aDVm v_aDVn) r_aDYp => k_aDVm -> v_aDVn -> Sem r_aDYp ()
+ Polysemy.SetStore: delS :: forall k_aE20 v_aE21 r_aE53. MemberWithError (SetStore k_aE20 v_aE21) r_aE53 => k_aE20 -> v_aE21 -> Sem r_aE53 ()
- Polysemy.SetStore: memberS :: forall k_aDVm v_aDVn r_aDYs. MemberWithError (SetStore k_aDVm v_aDVn) r_aDYs => k_aDVm -> v_aDVn -> Sem r_aDYs Bool
+ Polysemy.SetStore: memberS :: forall k_aE20 v_aE21 r_aE56. MemberWithError (SetStore k_aE20 v_aE21) r_aE56 => k_aE20 -> v_aE21 -> Sem r_aE56 Bool
Files
- ChangeLog.md +6/−3
- polysemy-zoo.cabal +2/−2
- src/Polysemy/Final.hs +15/−9
- src/Polysemy/Final/Error.hs +2/−0
- src/Polysemy/Final/Fixpoint.hs +1/−0
- src/Polysemy/Final/MTL.hs +4/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for polysemy-zoo +## 0.4.0.1 (2019-07-10)++- Fixed an erroneous lower bound in the tests+ ## 0.4.0.0 (2019-07-10) ### Breaking Changes@@ -10,6 +14,8 @@ - Added `SetStore` effect - Added `Floodgate` effect+- Added `Final` effect, together with submodules of interpreters using it+ (thanks to @KingoftheHomeless) - Added `lookupOrThrowKV`, `existsKV` and `modifyKV` actions to `KVStore` - Added Redis interpretations of `SetStore` and `KVStore` @@ -43,6 +49,3 @@ ## Unreleased changes--* In AbsorbMonadWriter, re-implemented mtl pass in terms of the new Polysemy.Writer-pass and confirmed all tests.
polysemy-zoo.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 2a632f7d2c785cf339754bf2cf1895a7996a6b348cc8704e54e6b45769f39d91+-- hash: 9c68e7c2421eb030fe99a14dcd7cc393f3aaf7a1f3874b559a2222ba3073e8ae name: polysemy-zoo-version: 0.4.0.0+version: 0.4.0.1 synopsis: Experimental, user-contributed effects and interpreters for polysemy description: Please see the README on GitHub at <https://github.com/isovector/polysemy-zoo#readme> category: Polysemy
src/Polysemy/Final.hs view
@@ -57,6 +57,7 @@ -- This is very useful for writing interpreters that interpret higher-order -- effects in terms of the final monad - however, these interpreters -- are subject to very different semantics than regular ones.+-- -- For more information, see 'interpretFinal'. data Final m z a where WithWeaving :: (forall f.@@ -113,11 +114,11 @@ -- interpret higher-order effects in terms of the final monad. -- -- /Beware/: Any interpreters built using this (or 'Final' in general)--- will _not_ respect local/global state semantics based on the order of+-- will /not/ respect local/global state semantics based on the order of -- interpreters run. You should signal interpreters that make use of -- 'Final' by adding a "-Final" suffix to the names of these. ----- State semantics of effects that are _not_+-- State semantics of effects that are /not/ -- interpreted in terms of the final monad will always -- appear local to effects that are interpreted in terms of the final monad. --@@ -170,6 +171,7 @@ getInspectorS = getInspectorT {-# INLINE getInspectorS #-} +------------------------------------------------------------------------------ -- | Get the stateful environment of the world at the moment the -- target monad is to be run. -- Prefer 'pureS', 'runS' or 'bindS' instead of using this function@@ -179,13 +181,13 @@ {-# INLINE getInitialStateS #-} --------------------------------------------------------------------------------- Lift a value into 'Strategic'.+-- | Lift a value into 'Strategic'. pureS :: Applicative m => a -> Strategic m n a pureS = fmap pure . pureT {-# INLINE pureS #-} --------------------------------------------------------------------------------- Lifts an action of the final monad into 'Strategic'.+-- | Lifts an action of the final monad into 'Strategic'. -- -- Note: you don't need to use this function if you already have a monadic -- action with the functorial state woven into it, by the use of@@ -230,9 +232,10 @@ GetInitialState -> s HoistInterpretation na -> sendM . wv . fmap na GetInspector -> Inspector ins+{-# INLINE runStrategy #-} --------------------------------------------------------------------------------- Lower a 'Sem' containing only a lifted, final monad into that monad.+-- | Lower a 'Sem' containing only a lifted, final monad into that monad. -- The appearance of 'Lift' as the final effect -- is to allow the use of operations that rely on a @'LastMember' ('Lift' m)@ -- constraint.@@ -242,16 +245,17 @@ ex <$> wav s (runFinal . wv) ins Left g -> case extract g of Weaving (Lift m) s _ ex _ -> ex . (<$ s) <$> m+{-# INLINE runFinal #-} --------------------------------------------------------------------------------- Lower a 'Sem' containing two lifted monad into the final monad,+-- | Lower a 'Sem' containing two lifted monad into the final monad, -- by interpreting one of the monads in terms of the other one. -- -- This allows for the use of operations that rely on a @'LastMember' ('Lift' m)@ -- constraint, as long as @m@ can be transformed to the final monad; -- but be warned, this breaks the implicit contract of @'LastMember' ('Lift' m)@--- that @m@ _is_ the final monad, so depending on the final monad and operations--- used, 'runFinalTrans' may become _unsafe_.+-- that @m@ /is/ the final monad, so depending on the final monad and operations+-- used, 'runFinalTrans' may become /unsafe/. -- -- For example, 'runFinalTrans' is unsafe with 'runAsync' if -- the final monad is non-deterministic, or a continuation@@ -267,10 +271,12 @@ Right (Weaving (Lift m) s _ ex _) -> ex . (<$ s) <$> m Left g' -> case extract g' of Weaving (Lift n) s _ ex _ -> ex . (<$ s) <$> nat n+{-# INLINE runFinalLift #-} --------------------------------------------------------------------------------- | 'runFinalTrans', specialized to transform 'IO' to a 'MonadIO'.+-- | 'runFinalLift', specialized to transform 'IO' to a 'MonadIO'. runFinalLiftIO :: MonadIO m => Sem [Final m, Lift m, Lift IO] a -> m a runFinalLiftIO = runFinalLift liftIO+{-# INLINE runFinalLiftIO #-}
src/Polysemy/Final/Error.hs view
@@ -34,6 +34,7 @@ ((<$ s) . Left . unwrapExc) (fmap Right) <$> try m'+{-# INLINE runErrorInIOFinal #-} runErrorAsExcFinal :: forall e r a@@ -50,6 +51,7 @@ s <- getInitialStateS pure $ X.catch m' $ \(se :: WrappedExc e) -> h' (unwrapExc se <$ s)+{-# INLINE runErrorAsExcFinal #-} newtype WrappedExc e = WrappedExc { unwrapExc :: e }
src/Polysemy/Final/Fixpoint.hs view
@@ -20,3 +20,4 @@ Fixpoint f -> do f' <- bindS f pure $ mfix f'+{-# INLINE runFixpointFinal #-}
src/Polysemy/Final/MTL.hs view
@@ -35,7 +35,7 @@ h' <- bindS h s <- getInitialStateS pure $ m' `catchError` (h' . (<$ s))-+{-# INLINE runErrorFinal #-} ----------------------------------------------------------------------------- -- | Run a 'Reader' effect through a final 'MonadReader'@@ -51,6 +51,7 @@ Local f m -> do m' <- runS m pure $ local f m'+{-# INLINE runReaderFinal #-} ----------------------------------------------------------------------------- -- | Run a 'State' effect through a 'MonadState'@@ -69,6 +70,7 @@ runStateFinal = interpret $ \case Get -> sendM get Put s -> sendM (put s)+{-# INLINE runStateFinal #-} ----------------------------------------------------------------------------- -- | Run a 'Writer' effect through a final 'MonadWriter'@@ -92,3 +94,4 @@ t <- m' let f = maybe id fst (inspect ins t) pure (fmap snd t, f)+{-# INLINE runWriterFinal #-}