polysemy-zoo 0.7.0.0 → 0.7.0.1
raw patch · 15 files changed
+65/−88 lines, 15 filesdep ~constraintsdep ~ghc-primdep ~randomPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: constraints, ghc-prim, random, streaming
API changes (from Hackage documentation)
- Polysemy.Capture: capture :: Member (Capture ref) r => (forall s. (a -> Sem r s) -> Sem r s) -> Sem r a
+ Polysemy.Capture: capture :: forall ref r a. Member (Capture ref) r => (forall s. (a -> Sem r s) -> Sem r s) -> Sem r a
- Polysemy.ConstraintAbsorber.MonadCont: absorbCont :: Member (Cont ref) r => (MonadCont (Sem r) => Sem r a) -> Sem r a
+ Polysemy.ConstraintAbsorber.MonadCont: absorbCont :: forall ref r a. Member (Cont ref) r => (MonadCont (Sem r) => Sem r a) -> Sem r a
- Polysemy.EndState: getEndState :: forall s_aA6w r_aA7p. MemberWithError (EndState s_aA6w) r_aA7p => Sem r_aA7p s_aA6w
+ Polysemy.EndState: getEndState :: forall s_atmD r_atnw. MemberWithError (EndState s_atmD) r_atnw => Sem r_atnw s_atmD
- Polysemy.EndState: runEndAtomicState :: (Member (AtomicState s) r, Member Fixpoint r) => Sem (EndState s : r) a -> Sem r a
+ Polysemy.EndState: runEndAtomicState :: forall s r a. (Member (AtomicState s) r, Member Fixpoint r) => Sem (EndState s : r) a -> Sem r a
- Polysemy.EndState: runEndState :: (Member (State s) r, Member Fixpoint r) => Sem (EndState s : r) a -> Sem r a
+ Polysemy.EndState: runEndState :: forall s r a. (Member (State s) r, Member Fixpoint r) => Sem (EndState s : r) a -> Sem r a
- Polysemy.Final.MTL: errorToFinal :: (Member (Final m) r, MonadError e m) => Sem (Error e : r) a -> Sem r a
+ Polysemy.Final.MTL: errorToFinal :: forall m e r a. (Member (Final m) r, MonadError e m) => Sem (Error e : r) a -> Sem r a
- Polysemy.Final.MTL: readerToFinal :: (Member (Final m) r, MonadReader i m) => Sem (Reader i : r) a -> Sem r a
+ Polysemy.Final.MTL: readerToFinal :: forall m i r a. (Member (Final m) r, MonadReader i m) => Sem (Reader i : r) a -> Sem r a
- Polysemy.Final.MTL: stateToEmbed :: (Member (Embed m) r, MonadState s m) => Sem (State s : r) a -> Sem r a
+ Polysemy.Final.MTL: stateToEmbed :: forall m s r a. (Member (Embed m) r, MonadState s m) => Sem (State s : r) a -> Sem r a
- Polysemy.Final.MTL: writerToFinal :: (Member (Final m) r, MonadWriter o m) => Sem (Writer o : r) a -> Sem r a
+ Polysemy.Final.MTL: writerToFinal :: forall m o r a. (Member (Final m) r, MonadWriter o m) => Sem (Writer o : r) a -> Sem r a
- Polysemy.Final.NonDet: nonDetToFinal :: (Member (Final m) r, Alternative m) => Sem (NonDet : r) a -> Sem r a
+ Polysemy.Final.NonDet: nonDetToFinal :: forall m r a. (Member (Final m) r, Alternative m) => Sem (NonDet : r) a -> Sem r a
- Polysemy.Floodgate: hold :: forall r_aoMw. MemberWithError Floodgate r_aoMw => Sem r_aoMw () -> Sem r_aoMw ()
+ Polysemy.Floodgate: hold :: forall r_agIr. MemberWithError Floodgate r_agIr => Sem r_agIr () -> Sem r_agIr ()
- Polysemy.Floodgate: release :: forall r_aoMy. MemberWithError Floodgate r_aoMy => Sem r_aoMy ()
+ Polysemy.Floodgate: release :: forall r_agIt. MemberWithError Floodgate r_agIt => Sem r_agIt ()
- Polysemy.Fresh: fresh :: forall uniq_augT r_auhM. MemberWithError (Fresh uniq_augT) r_auhM => Sem r_auhM uniq_augT
+ Polysemy.Fresh: fresh :: forall uniq_alGM r_alHF. MemberWithError (Fresh uniq_alGM) r_alHF => Sem r_alHF uniq_alGM
- Polysemy.KVStore: deleteKV :: Member (KVStore k v) r => k -> Sem r ()
+ Polysemy.KVStore: deleteKV :: forall k v r. Member (KVStore k v) r => k -> Sem r ()
- Polysemy.KVStore: existsKV :: Member (KVStore k v) r => k -> Sem r Bool
+ Polysemy.KVStore: existsKV :: forall k v r. Member (KVStore k v) r => k -> Sem r Bool
- Polysemy.KVStore: lookupKV :: forall k_ayqZ v_ayr0 r_aysT. MemberWithError (KVStore k_ayqZ v_ayr0) r_aysT => k_ayqZ -> Sem r_aysT (Maybe v_ayr0)
+ Polysemy.KVStore: lookupKV :: forall k_arsB v_arsC r_arut. MemberWithError (KVStore k_arsB v_arsC) r_arut => k_arsB -> Sem r_arut (Maybe v_arsC)
- Polysemy.KVStore: updateKV :: forall k_ayr2 v_ayr3 r_aysV. MemberWithError (KVStore k_ayr2 v_ayr3) r_aysV => k_ayr2 -> Maybe v_ayr3 -> Sem r_aysV ()
+ Polysemy.KVStore: updateKV :: forall k_arsE v_arsF r_aruv. MemberWithError (KVStore k_arsE v_arsF) r_aruv => k_arsE -> Maybe v_arsF -> Sem r_aruv ()
- Polysemy.Random: random :: forall r_azvr x_aztH. (MemberWithError Random r_azvr, Random x_aztH) => Sem r_azvr x_aztH
+ Polysemy.Random: random :: forall r_ast9 x_asrp. (MemberWithError Random r_ast9, Random x_asrp) => Sem r_ast9 x_asrp
- Polysemy.Random: randomR :: forall r_azvs x_aztJ. (MemberWithError Random r_azvs, Random x_aztJ) => (x_aztJ, x_aztJ) -> Sem r_azvs x_aztJ
+ Polysemy.Random: randomR :: forall r_asta x_asrr. (MemberWithError Random r_asta, Random x_asrr) => (x_asrr, x_asrr) -> Sem r_asta x_asrr
- Polysemy.SetStore: addS :: forall k_aByo v_aByp r_aBBk. MemberWithError (SetStore k_aByo v_aByp) r_aBBk => k_aByo -> v_aByp -> Sem r_aBBk ()
+ Polysemy.SetStore: addS :: forall k_avJy v_avJz r_avMu. MemberWithError (SetStore k_avJy v_avJz) r_avMu => k_avJy -> v_avJz -> Sem r_avMu ()
- Polysemy.SetStore: delS :: forall k_aByr v_aBys r_aBBn. MemberWithError (SetStore k_aByr v_aBys) r_aBBn => k_aByr -> v_aBys -> Sem r_aBBn ()
+ Polysemy.SetStore: delS :: forall k_avJB v_avJC r_avMx. MemberWithError (SetStore k_avJB v_avJC) r_avMx => k_avJB -> v_avJC -> Sem r_avMx ()
- Polysemy.SetStore: memberS :: forall k_aByu v_aByv r_aBBq. MemberWithError (SetStore k_aByu v_aByv) r_aBBq => k_aByu -> v_aByv -> Sem r_aBBq Bool
+ Polysemy.SetStore: memberS :: forall k_avJE v_avJF r_avMA. MemberWithError (SetStore k_avJE v_avJF) r_avMA => k_avJE -> v_avJF -> Sem r_avMA Bool
- Polysemy.Shift: shift :: Member (Shift ref s) r => ((a -> Sem r s) -> Sem r s) -> Sem r a
+ Polysemy.Shift: shift :: forall ref s r a. Member (Shift ref s) r => ((a -> Sem r s) -> Sem r s) -> Sem r a
Files
- ChangeLog.md +4/−0
- polysemy-zoo.cabal +13/−15
- src/Polysemy/Capture.hs +4/−3
- src/Polysemy/ConstraintAbsorber/MonadCont.hs +4/−2
- src/Polysemy/Cont.hs +2/−2
- src/Polysemy/Cont/Internal.hs +2/−2
- src/Polysemy/EndState.hs +6/−4
- src/Polysemy/Final/MTL.hs +14/−9
- src/Polysemy/Final/NonDet.hs +4/−2
- src/Polysemy/Floodgate.hs +1/−1
- src/Polysemy/KVStore.hs +5/−5
- src/Polysemy/Random.hs +1/−1
- src/Polysemy/Shift.hs +4/−3
- src/Polysemy/Shift/Internal.hs +1/−1
- test/IdempotentLoweringSpec.hs +0/−38
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for polysemy-zoo ++## 0.7.0.1 (2020-10-06)+* As a stop-gap for [#65](https://github.com/polysemy-research/polysemy-zoo/issues/65), the library has been rewritten to no longer use `polysemy-plugin`. This should allow GHC 8.10 users to use the library.+ ## 0.7.0.0 (2020-02-14) ### Breaking Changes - `Tagged` has been migrated to `polysemy` proper.
polysemy-zoo.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 3ca3f0fd7140b4210529e77e057687ebd67bb4477155611458e964afa5cdc192+-- hash: a5563140d5d76f52bdcb2c1def770fca8613155455f2e76e5286d6a5cd6505a3 name: polysemy-zoo-version: 0.7.0.0+version: 0.7.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@@ -64,22 +64,21 @@ hs-source-dirs: src default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax- ghc-options: -fplugin=Polysemy.Plugin -Wall+ ghc-options: -Wall build-depends: async >=2.2 && <3 , base >=4.9 && <5 , compact >=0.1.0.1- , constraints >=0.10.1 && <0.12+ , constraints >=0.10.1 && <0.13 , containers >=0.5 && <0.7 , contravariant <2 , exceptions >=0.10.0 && <0.11- , ghc-prim >=0.5.2 && <0.6+ , ghc-prim >=0.5.2 && <0.7 , mtl >=2.0.1.0 && <3.0.0.0 , polysemy >=1.2.1.0- , polysemy-plugin >=0.2- , random >=1.1 && <1.2+ , random >=1.1 && <1.3 , reflection >=2.1.4 && <3.0.0- , streaming+ , streaming >=0.2 && <0.3 , text >=1.1.0 && <1.3 , transformers >=0.5.2.0 && <0.6 default-language: Haskell2010@@ -93,7 +92,6 @@ ContSpec FinalSpec FloodgateSpec- IdempotentLoweringSpec KVStoreSpec RevStateSpec SeveralSpec@@ -102,26 +100,26 @@ hs-source-dirs: test default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax- ghc-options: -fplugin=Polysemy.Plugin -Wall -threaded -rtsopts -with-rtsopts=-N+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -fplugin=Polysemy.Plugin build-tool-depends: hspec-discover:hspec-discover >=2.0 build-depends: async >=2.2 && <3 , base >=4.9 && <5 , compact >=0.1.0.1- , constraints >=0.10.1 && <0.12+ , constraints >=0.10.1 && <0.13 , containers >=0.5 && <0.7 , contravariant <2 , exceptions >=0.10.0 && <0.11- , ghc-prim >=0.5.2 && <0.6+ , ghc-prim >=0.5.2 && <0.7 , hspec >=2.6.0 && <3 , mtl >=2.0.1.0 && <3.0.0.0 , polysemy >=1.2.0.0 , polysemy-plugin >=0.2 , polysemy-zoo- , random >=1.1 && <1.2+ , random >=1.1 && <1.3 , reflection >=2.1.4 && <3.0.0- , streaming+ , streaming >=0.2 && <0.3 , text >=1.1.0 && <1.3 , transformers >=0.5.2.0 && <0.6 default-language: Haskell2010
src/Polysemy/Capture.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell, Trustworthy #-}+{-# LANGUAGE AllowAmbiguousTypes, TemplateHaskell, Trustworthy #-} module Polysemy.Capture (-- * Effect Capture(..)@@ -92,10 +92,11 @@ -- which case such failure may be detected by using 'delimit'' together -- with the provided continuation (the provided continuation -- is already delimited).-capture :: Member (Capture ref) r+capture :: forall ref r a+ . Member (Capture ref) r => (forall s. (a -> Sem r s) -> Sem r s) -> Sem r a-capture cc = reify (\ref -> cc (reflect ref))+capture cc = reify @ref (\ref -> cc (reflect ref)) {-# INLINE capture #-} -----------------------------------------------------------------------------
src/Polysemy/ConstraintAbsorber/MonadCont.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -20,13 +21,14 @@ -- -- @since 0.3.0.0 absorbCont- :: Member (Cont ref) r+ :: forall ref r a+ . Member (Cont ref) r => (C.MonadCont (Sem r) => Sem r a) -- ^ A computation that requires an instance of 'C.MonadCont' for -- 'Sem'. This might be something with type @'C.MonadCont' m => m a@. -> Sem r a absorbCont = absorbWithSem @C.MonadCont @Action- (ContDict callCC)+ (ContDict (callCC @ref)) (Sub Dict) {-# INLINEABLE absorbCont #-}
src/Polysemy/Cont.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE AllowAmbiguousTypes, Trustworthy #-} module Polysemy.Cont (-- * Effect Cont(..)@@ -56,7 +56,7 @@ . Member (Cont ref) r => ((forall b. a -> Sem r b) -> Sem r a) -> Sem r a-callCC cc = subst (\ref -> cc (jump ref)) pure+callCC cc = subst @ref (\ref -> cc (jump ref)) pure {-# INLINE callCC #-} -----------------------------------------------------------------------------
src/Polysemy/Cont/Internal.hs view
@@ -174,7 +174,7 @@ if ref == ref' then loop (cn' $ unsafeCoerce a') else- throw x+ throw @(uniq, Any) x loop $ main' $ ViaFreshRef (\a -> (ref, unsafeCoerce a)) Jump ref a -> throw (getBacktrackException ref a) Left g -> do@@ -218,7 +218,7 @@ if ref == ref' then loop (cn' $ unsafeCoerce a') else- throw x+ throw @(uniq, Any) x ResAndHandler res h <- loop $ main' $ ViaFreshRef (\a -> (ref, unsafeCoerce a)) return $ ResAndHandler res
src/Polysemy/EndState.hs view
@@ -30,20 +30,22 @@ ----------------------------------------------------------------------------- -- | Runs an 'EndState' effect by getting the state after the computation -- has finished, and providing it recursively back to calls of 'getEndState'.-runEndState :: (Member (State s) r, Member Fixpoint r)+runEndState :: forall s r a+ . (Member (State s) r, Member Fixpoint r) => Sem (EndState s ': r) a -> Sem r a runEndState =- runReaderFixSem get+ runReaderFixSem (get @s) . reinterpret (\GetEndState -> ask) ----------------------------------------------------------------------------- -- | Like 'runEndState', but for 'AtomicState' rather than 'State'. runEndAtomicState- :: (Member (AtomicState s) r, Member Fixpoint r)+ :: forall s r a+ . (Member (AtomicState s) r, Member Fixpoint r) => Sem (EndState s ': r) a -> Sem r a runEndAtomicState =- runReaderFixSem atomicGet+ runReaderFixSem (atomicGet @s) . reinterpret (\GetEndState -> ask)
src/Polysemy/Final/MTL.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE AllowAmbiguousTypes #-} module Polysemy.Final.MTL ( module Polysemy.Final@@ -25,10 +26,11 @@ -- /Beware/: Effects that aren't interpreted in terms of the final -- monad will have local state semantics in regards to 'Error' effects -- interpreted this way. See 'Final'.-errorToFinal :: (Member (Final m) r, MonadError e m)+errorToFinal :: forall m e r a+ . (Member (Final m) r, MonadError e m) => Sem (Error e ': r) a -> Sem r a-errorToFinal = interpretFinal $ \case+errorToFinal = interpretFinal @m $ \case Throw e -> pure $ throwError e Catch m h -> do m' <- runS m@@ -43,10 +45,11 @@ -- /Beware/: Effects that aren't interpreted in terms of the final -- monad will have local state semantics in regards to 'Reader' effects -- interpreted this way. See 'Final'.-readerToFinal :: (Member (Final m) r, MonadReader i m)+readerToFinal :: forall m i r a+ . (Member (Final m) r, MonadReader i m) => Sem (Reader i ': r) a -> Sem r a-readerToFinal = interpretFinal $ \case+readerToFinal = interpretFinal @m $ \case Ask -> liftS ask Local f m -> do m' <- runS m@@ -64,12 +67,13 @@ -- /Beware/: Effects that aren't interpreted in terms of the embedded -- monad will have local state semantics in regards to 'State' effects -- interpreted this way. See 'Final'.-stateToEmbed :: (Member (Embed m) r, MonadState s m)+stateToEmbed :: forall m s r a+ . (Member (Embed m) r, MonadState s m) => Sem (State s ': r) a -> Sem r a stateToEmbed = interpret $ \case- Get -> embed get- Put s -> embed (put s)+ Get -> embed @m get+ Put s -> embed @m (put s) {-# INLINE stateToEmbed #-} -----------------------------------------------------------------------------@@ -78,10 +82,11 @@ -- /Beware/: Effects that aren't interpreted in terms of the final -- monad will have local state semantics in regards to 'Writer' effects -- interpreted this way. See 'Final'.-writerToFinal :: (Member (Final m) r, MonadWriter o m)+writerToFinal :: forall m o r a+ . (Member (Final m) r, MonadWriter o m) => Sem (Writer o ': r) a -> Sem r a-writerToFinal = interpretFinal $ \case+writerToFinal = interpretFinal @m $ \case Tell s -> liftS (tell s) Listen m -> do m' <- runS m
src/Polysemy/Final/NonDet.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE AllowAmbiguousTypes #-} module Polysemy.Final.NonDet ( module Polysemy.NonDet@@ -16,10 +17,11 @@ -- /Beware/: Effects that aren't interpreted in terms of the final -- monad will have local state semantics in regards to 'NonDet' effects -- interpreted this way. See 'Final'.-nonDetToFinal :: (Member (Final m) r, Alternative m)+nonDetToFinal :: forall m r a+ . (Member (Final m) r, Alternative m) => Sem (NonDet ': r) a -> Sem r a-nonDetToFinal = interpretFinal $ \case+nonDetToFinal = interpretFinal @m $ \case Empty -> pure empty Choose left right -> do left' <- runS left
src/Polysemy/Floodgate.hs view
@@ -46,7 +46,7 @@ getInitialStateT Release -> do- ms' <- gets (fmap unsafeCoerce . reverse)+ ms' <- gets @[Any] (fmap unsafeCoerce . reverse) sequence_ ms' getInitialStateT )
src/Polysemy/KVStore.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE AllowAmbiguousTypes, TemplateHaskell #-} module Polysemy.KVStore ( -- * Effect@@ -40,8 +40,8 @@ {-# INLINE writeKV #-} -deleteKV :: Member (KVStore k v) r => k -> Sem r ()-deleteKV k = updateKV k Nothing+deleteKV :: forall k v r. Member (KVStore k v) r => k -> Sem r ()+deleteKV k = updateKV k (Nothing @v) {-# INLINE deleteKV #-} @@ -64,8 +64,8 @@ -- | -- -- @since 0.3.1.0-existsKV :: Member (KVStore k v) r => k -> Sem r Bool-existsKV = fmap isJust . lookupKV+existsKV :: forall k v r. Member (KVStore k v) r => k -> Sem r Bool+existsKV = fmap isJust . lookupKV @k @v ------------------------------------------------------------------------------
src/Polysemy/Random.hs view
@@ -51,7 +51,7 @@ -- | Run a 'Random' effect by using the 'IO' random generator. runRandomIO :: Member (Embed IO) r => Sem (Random ': r) a -> Sem r a runRandomIO m = do- q <- embed R.newStdGen+ q <- embed @IO R.newStdGen snd <$> runRandom q m {-# INLINE runRandomIO #-}
src/Polysemy/Shift.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE AllowAmbiguousTypes, Trustworthy #-} module Polysemy.Shift ( module Polysemy.Cont@@ -62,10 +62,11 @@ -- It may sometimes become necessary to handle such cases, in -- which case such failure may be detected by using 'reset\'' together -- with the provided continuation.-shift :: Member (Shift ref s) r+shift :: forall ref s r a+ . Member (Shift ref s) r => ((a -> Sem r s) -> Sem r s) -> Sem r a-shift cc = trap $ \ref -> cc (invoke ref)+shift cc = trap @ref $ \ref -> cc (invoke ref) {-# INLINE shift #-} -----------------------------------------------------------------------------
src/Polysemy/Shift/Internal.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE AllowAmbiguousTypes, TemplateHaskell #-} module Polysemy.Shift.Internal where import Polysemy
− test/IdempotentLoweringSpec.hs
@@ -1,38 +0,0 @@-{-# LANGUAGE ImpredicativeTypes #-}-{-# OPTIONS_GHC -Wno-deprecations #-}-module IdempotentLoweringSpec where--import Data.IORef-import Polysemy-import Polysemy.State-import Polysemy.IdempotentLowering-import Polysemy.Resource-import Test.Hspec---runStateInIO :: Member (Embed IO) r => s -> IO (∀ x. Sem (State s ': r) x -> Sem r x)-runStateInIO s = do- ref <- newIORef s- nat $ runStateIORef ref---test- :: ( Member Resource r- , Member (State Int) r- )- => Sem r Int-test = do- bracket- (modify (+1))- (const $ modify (+1))- (const $ modify (+1))- get---spec :: Spec-spec = describe "Idempotent Lowering" $ do- it "should persist an IORef through a bracket" $ do- runIt <- nat runM .@! const (runStateInIO 0) .@! liftNat lowerResource- result <- runIt test- result `shouldBe` (3 :: Int)-