packages feed

polysemy-zoo 0.7.0.2 → 0.8.0.0

raw patch · 4 files changed

+10/−180 lines, 4 filesdep ~polysemyPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: polysemy

API changes (from Hackage documentation)

- Polysemy.IdempotentLowering: (.@!) :: (Monad base, Monad m) => base (forall x. Sem r x -> m x) -> ((forall x. Sem r x -> m x) -> base (forall y. Sem (e : r) y -> Sem r y)) -> base (forall z. Sem (e : r) z -> m z)
- Polysemy.IdempotentLowering: (.@@!) :: (Monad base, Monad m) => base (forall x. Sem r x -> m x) -> ((forall x. Sem r x -> m x) -> base (forall y. Sem (e : r) y -> Sem r (f y))) -> base (forall z. Sem (e : r) z -> m (f z))
- Polysemy.IdempotentLowering: fixedNat :: forall m n base. Applicative base => ((forall x. m x -> n x) -> forall x. m x -> n x) -> base (forall x. m x -> n x)
- Polysemy.IdempotentLowering: fixedNat' :: forall m n f base. Applicative base => ((forall x. m x -> n (f x)) -> forall x. m x -> n (f x)) -> base (forall x. m x -> n (f x))
- Polysemy.IdempotentLowering: infixl 8 .@@!
- Polysemy.IdempotentLowering: liftNat :: Applicative base => (forall x. (forall y. f y -> g y) -> m x -> n x) -> (forall y. f y -> g y) -> base (forall x. m x -> n x)
- Polysemy.IdempotentLowering: liftNat' :: Applicative base => (forall x. (forall y. f y -> g y) -> m x -> n (f x)) -> (forall y. f y -> g y) -> base (forall x. m x -> n (f x))
- Polysemy.IdempotentLowering: nat :: Applicative base => (forall x. m x -> n x) -> base (forall x. m x -> n x)
- Polysemy.IdempotentLowering: nat' :: Applicative base => (forall x. m x -> n (f x)) -> base (forall x. m x -> n (f x))
- Polysemy.EndState: getEndState :: forall s_akW2 r_akWU. MemberWithError (EndState s_akW2) r_akWU => Sem r_akWU s_akW2
+ Polysemy.EndState: getEndState :: forall s_ajgl r_ajhd. Member (EndState s_ajgl) r_ajhd => Sem r_ajhd s_ajgl
- Polysemy.Floodgate: hold :: forall r_abHa. MemberWithError Floodgate r_abHa => Sem r_abHa () -> Sem r_abHa ()
+ Polysemy.Floodgate: hold :: forall r_abou. Member Floodgate r_abou => Sem r_abou () -> Sem r_abou ()
- Polysemy.Floodgate: release :: forall r_abHc. MemberWithError Floodgate r_abHc => Sem r_abHc ()
+ Polysemy.Floodgate: release :: forall r_abow. Member Floodgate r_abow => Sem r_abow ()
- Polysemy.Fresh: fresh :: forall uniq_ae5U r_ae6M. MemberWithError (Fresh uniq_ae5U) r_ae6M => Sem r_ae6M uniq_ae5U
+ Polysemy.Fresh: fresh :: forall uniq_abWh r_abX9. Member (Fresh uniq_abWh) r_abX9 => Sem r_abX9 uniq_abWh
- Polysemy.KVStore: lookupKV :: forall k_ajgn v_ajgo r_ajig. MemberWithError (KVStore k_ajgn v_ajgo) r_ajig => k_ajgn -> Sem r_ajig (Maybe v_ajgo)
+ Polysemy.KVStore: lookupKV :: forall k_ahX7 v_ahX8 r_ahZ0. Member (KVStore k_ahX7 v_ahX8) r_ahZ0 => k_ahX7 -> Sem r_ahZ0 (Maybe v_ahX8)
- Polysemy.KVStore: updateKV :: forall k_ajgq v_ajgr r_ajii. MemberWithError (KVStore k_ajgq v_ajgr) r_ajii => k_ajgq -> Maybe v_ajgr -> Sem r_ajii ()
+ Polysemy.KVStore: updateKV :: forall k_ahXa v_ahXb r_ahZ2. Member (KVStore k_ahXa v_ahXb) r_ahZ2 => k_ahXa -> Maybe v_ahXb -> Sem r_ahZ2 ()
- Polysemy.Random: random :: forall r_ak96 x_ak7u. (MemberWithError Random r_ak96, Random x_ak7u) => Sem r_ak96 x_ak7u
+ Polysemy.Random: random :: forall r_aiAG x_aiz4. (Member Random r_aiAG, Random x_aiz4) => Sem r_aiAG x_aiz4
- Polysemy.Random: randomR :: forall r_ak97 x_ak7w. (MemberWithError Random r_ak97, Random x_ak7w) => (x_ak7w, x_ak7w) -> Sem r_ak97 x_ak7w
+ Polysemy.Random: randomR :: forall r_aiAH x_aiz6. (Member Random r_aiAH, Random x_aiz6) => (x_aiz6, x_aiz6) -> Sem r_aiAH x_aiz6
- Polysemy.SetStore: addS :: forall k_ancz v_ancA r_anfx. MemberWithError (SetStore k_ancz v_ancA) r_anfx => k_ancz -> v_ancA -> Sem r_anfx ()
+ Polysemy.SetStore: addS :: forall k_alml v_almm r_alpj. Member (SetStore k_alml v_almm) r_alpj => k_alml -> v_almm -> Sem r_alpj ()
- Polysemy.SetStore: delS :: forall k_ancC v_ancD r_anfA. MemberWithError (SetStore k_ancC v_ancD) r_anfA => k_ancC -> v_ancD -> Sem r_anfA ()
+ Polysemy.SetStore: delS :: forall k_almo v_almp r_alpm. Member (SetStore k_almo v_almp) r_alpm => k_almo -> v_almp -> Sem r_alpm ()
- Polysemy.SetStore: memberS :: forall k_ancF v_ancG r_anfD. MemberWithError (SetStore k_ancF v_ancG) r_anfD => k_ancF -> v_ancG -> Sem r_anfD Bool
+ Polysemy.SetStore: memberS :: forall k_almr v_alms r_alpp. Member (SetStore k_almr v_alms) r_alpp => k_almr -> v_alms -> Sem r_alpp Bool

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for polysemy-zoo+## 0.8.0.0 (2022-03-08)+### Breaking Changes+- Removed `Polysemy.IdempotentLowering`, previously deprecated in favor of `Polysemy.Final`. +### Other Changes+- Updated `asyncToIOFinalGlobal` to support `cancel`.+ ## 0.7.0.2 (2020-11-04) - Add support for GHC 9.0   ([#70](https://github.com/polysemy-research/polysemy-zoo/pull/70), thanks to @funketh)@@ -103,6 +109,3 @@ ## 0.1.1.0 (2019-05-22)  - Added `Polysemy.IdempotentLowering`---## Unreleased changes
polysemy-zoo.cabal view
@@ -1,13 +1,11 @@-cabal-version: 1.12+cabal-version: 1.12
  -- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 21ba8ceb18ae6184f65237f20847dd9e3f23ad2838d46fc1cd6af719dac66eb3  name:           polysemy-zoo-version:        0.7.0.2+version:        0.8.0.0 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@@ -47,7 +45,6 @@       Polysemy.Final.NonDet       Polysemy.Floodgate       Polysemy.Fresh-      Polysemy.IdempotentLowering       Polysemy.Input.Streaming       Polysemy.KVStore       Polysemy.Operators@@ -88,7 +85,7 @@     , exceptions >=0.10.0 && <0.11     , ghc-prim >=0.5.2 && <0.8     , mtl >=2.0.1.0 && <3.0.0.0-    , polysemy >=1.2.1.0+    , polysemy >=1.4.0.0     , random >=1.1 && <1.3     , reflection >=2.1.4 && <3.0.0     , streaming ==0.2.*
src/Polysemy/Final/IO.hs view
@@ -32,6 +32,7 @@     m'  <- runS m     liftS $ A.async (inspect ins <$> m')   Await a -> liftS (A.wait a)+  Cancel a -> liftS (A.cancel a) {-# INLINE asyncToIOFinalGlobal #-} ------------------------------------------------------------------------------ -- | 'resourceToIOFinal' implemented using 'interpretFinalGlobal'.
− src/Polysemy/IdempotentLowering.hs
@@ -1,171 +0,0 @@-{-# LANGUAGE ImpredicativeTypes #-}--- | =__Unless you absolutely have to use explicit lowering functions, use "Polysemy.Final" instead__-module Polysemy.IdempotentLowering-  ( (.@!)-  , nat-  , liftNat-  , fixedNat-  , (.@@!)-  , nat'-  , liftNat'-  , fixedNat'-  ) where--import Polysemy-import Data.Coerce--newtype Nat m n = Nat (∀ x. m x -> n x)----------------------------------------------------------------------------------- | This is just 'pure' but with a type specialised for lifting interpreters.------ @since 0.1.1.0-nat :: Applicative base => (∀ x. m x -> n x) -> base (∀ x. m x -> n x)-nat f = pure $ coerce $ Nat f--newtype Nat' m n f = Nat' (∀ x. m x -> n (f x))----------------------------------------------------------------------------------- | 'nat'' is to 'nat' as '.@@!' is to '.@!'.------ @since 0.1.1.0-nat' :: Applicative base => (∀ x. m x -> n (f x)) -> base (∀ x. m x -> n (f x))-nat' f = pure $ coerce $ Nat' f----------------------------------------------------------------------------------- | Like 'Polysemy..@', but useful for interpreters that wish to perform some--- initialization before being run. Most of the time, you don't want to--- duplicate this initialization every time your effect is lowered.------ Consider an interpreter which wants to use an 'Data.IORef.IORef' to store--- intermediary state. It might begin like this:------ @--- myIntepreter---     :: 'Polysemy.Member' ('Polysemy.Lift' 'IO') r---     => (∀ x. 'Polysemy.Sem' r x -> 'IO' x)---     -> 'Polysemy.Sem' (MyEff ': r) a---     -> 'Polysemy.Sem' r a--- myInterpreter lower sem = do---     ref <- 'Polysemy.sendM' $ 'Data.IORef.newIORef' 0---     go ref sem---   where---     go ref = 'Polysemy.interpretH' $ \e -> ...--- @------ This interpreter will do the wrong thing when composed via 'Polysemy..@'. It--- would have been correct if we didn't attempt to hide the creation of the--- 'Data.IORef.IORef', but that's an unfortunate side-effect of wanting to hide--- implementation details.------ Instead, we can write @myInterpreter@ thusly:------ @--- myIntepreter---     :: (∀ x. 'Polysemy.Sem' r x -> 'IO' x)---     -> 'IO' (∀ a. 'Polysemy.Sem' (MyEff ': r) a -> 'Polysemy.Sem' r a)--- myInterpreter lower = do---     ref <- 'Data.IORef.newIORef' 0---     'nat' $ 'Polysemy.interpretH' $ \e -> ...--- @------ and use '.@!' (rather than 'Polysemy..@') to compose these things together.------ Note: you must enable @-XImpredicativeTypes@ to give the correct type to--- @myInterpreter@ here. Don't worry, it's (probably) not as scary as it--- sounds.------ @since 0.1.1.0-(.@!)-    :: (Monad base, Monad m)-    => base (∀ x. Sem r x -> m x)-       -- ^ The lowering function, likely @nat runM@.-    -> ( (∀ x. Sem r x -> m x)-      -> base ( ∀ y-           . Sem (e ': r) y-          -> Sem r y-           )-       )-    -> base (∀ z. Sem (e ': r) z -> m z)-fi .@! gi = do-  f <- fi-  g <- gi (\x -> f x)-  nat $ \z -> f $ g z-infixl 8 .@!------------------------------------------------------------------------------------ | Like '.@!', but for interpreters which change the resulting type --- eg.--- 'Polysemy.Error.lowerError.------ @since 0.1.1.0-(.@@!)-    :: (Monad base, Monad m)-    => base (∀ x. Sem r x -> m x)-       -- ^ The lowering function, likely @nat runM@.-    -> ( (∀ x. Sem r x -> m x)-      -> base ( ∀ y-           . Sem (e ': r) y-          -> Sem r (f y)-           )-       )-    -> base (∀ z. Sem (e ': r) z -> m (f z))-fi .@@! gi = do-  f <- fi-  g <- gi (\x -> f x)-  nat' $ \z -> f $ g z-infixl 8 .@@!------------------------------------------------------------------------------------ | Lift a combinator designed to be used with 'Polysemy..@' into one designed--- to be used with 'Polysemy..@!'.-liftNat-  :: Applicative base-  => (forall x. (forall y. f y -> g y) -> m x -> n x)-  -> (forall y. f y -> g y) -> base (forall x. m x -> n x)-liftNat z a = nat $ z a----------------------------------------------------------------------------------- | Lift a combinator designed to be used with 'Polysemy..@@' into one designed--- to be used with 'Polysemy..@@!'.-liftNat'-  :: Applicative base-  => (forall x. (forall y. f y -> g y) -> m x -> n (f x))-  -> (forall y. f y -> g y) -> base (forall x. m x -> n (f x))-liftNat' z a = nat' $ z a------------------------------------------------------------------------------------ | Like 'nat', but for higher-order interpreters that need access to--- themselves.------ For example:------ @--- 'fixedNat' $ \me -> 'Polysemy.interpretH' $ \case---   SomeEffect -> ...--- @-fixedNat-    :: forall m n base-     . Applicative base-    => ((forall x. m x -> n x) -> (forall x. m x -> n x))-    -> base (forall x. m x -> n x)-fixedNat f =-  let x :: (forall x. m x -> n x)-      x = f x-   in nat x------------------------------------------------------------------------------------ | 'fixedNat'' is to 'fixedNat' as 'nat'' is to 'nat'.-fixedNat'-    :: forall m n f base-     . Applicative base-    => ((forall x. m x -> n (f x)) -> (forall x. m x -> n (f x)))-    -> base (forall x. m x -> n (f x))-fixedNat' f =-  let x :: (forall x. m x -> n (f x))-      x = f x-   in nat' x-