polysemy-check 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+17/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Polysemy.Check: prepropEquivalent :: forall effs x r1 r2. (Eq x, Show x, Inject effs r1, Inject effs r2, Members effs effs) => (forall a. Sem r1 a -> IO a) -> (forall a. Sem r2 a -> IO a) -> (forall r. Members effs r => Gen (Sem r x)) -> Property
+ Polysemy.Check: prepropEquivalent :: forall effs x r1 r2. (Eq x, Show x, Inject effs r1, Inject effs r2, Members effs effs) => (forall a. Sem r1 a -> IO a) -> (forall a. Sem r2 a -> IO a) -> (forall r. Proxy r -> Members effs r => Gen (Sem r x)) -> Property
Files
- ChangeLog.md +6/−0
- polysemy-check.cabal +1/−1
- src/Polysemy/Check.hs +3/−2
- test/EquivSpec.hs +7/−11
ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for polysemy-check +## v0.2.0.0 (2021-10-09)++- Updated the signature of `prepropEquivalent` to take a `Proxy r`. This lets+ you bind the `r` type variable, and use it as an argument to+ `arbitraryAction` et al.+ ## v0.1.0.0 (2021-10-08) - Released!
polysemy-check.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: polysemy-check-version: 0.1.0.0+version: 0.2.0.0 synopsis: QuickCheck for Polysemy description: Please see the README on GitHub at <https://github.com/polysemy-research/polysemy-check#readme> category: Polysemy
src/Polysemy/Check.hs view
@@ -29,6 +29,7 @@ , GenericK ) where +import Data.Proxy import Generics.Kind (GenericK) import Generics.Kind.TH (deriveGenericK) import Polysemy@@ -128,13 +129,13 @@ -- be lifted into 'IO' via 'pure' after the final 'run'. -> (forall a. Sem r2 a -> IO a) -- ^ The second interpreter to prove equivalence for.- -> (forall r. Members effs r => Gen (Sem r x))+ -> (forall r. Proxy r -> Members effs r => Gen (Sem r x)) -- ^ A generator producing arbitrary programs in @r@. The property will -- hold true if both interpreters produce the same output for every -- program generated by this. -> Property prepropEquivalent int1 int2 mksem = property $ do- SomeSem sem <- liftGen @effs @x mksem+ SomeSem sem <- liftGen @effs @x $ mksem Proxy pure $ ioProperty $ do a1 <- int1 sem a2 <- int2 sem
test/EquivSpec.hs view
@@ -5,14 +5,14 @@ module EquivSpec where +import Data.IORef (newIORef)+import Data.Proxy (Proxy) import Polysemy import Polysemy.Check+import Polysemy.State import Test.Hspec-import Test.QuickCheck import Test.Hspec.QuickCheck-import Polysemy.State-import Data.IORef (newIORef)-import Unsafe.Coerce (unsafeCoerce)+import Test.QuickCheck spec :: Spec@@ -23,15 +23,11 @@ prepropEquivalent @'[State Int] @Int (runPureState s0) (runIOState s0)- $ ((do+ $ \(_ :: Proxy r) -> do SomeAction e1 <- arbitraryAction @(State Int) @r SomeAction e2 <- arbitraryAction @(State Int) @r- SomeAction e3 <- arbitraryAction @(State Int) @r- -- TODO(sandy): e3 has an existential type! GHC doesn't care, but- -- AFAIK, thereis no syntax to return this type, since it doesn't- -- exist when we bind 'a' below.- pure $ send e1 >> send e2 >> unsafeCoerce (send e3)- ) :: forall r a. Member (State Int) r => Gen (Sem r a))+ e3 <- arbitraryActionOfType @(State Int) @Int @r+ pure $ send e1 >> send e2 >> send e3 runPureState :: Int -> Sem '[State Int] a -> IO a