packages feed

registry-hedgehog 0.2.0.0 → 0.2.0.1

raw patch · 2 files changed

+30/−19 lines, 2 files

Files

registry-hedgehog.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: caafc927ce38215ca10339479333651c7cf8ccfd5f25036542303ba286c1c3f6+-- hash: b9a7aaf16fbb1ffd70fc4abc0ff27630aa7fe083a34704f9074066e224ba4dc2  name:           registry-hedgehog-version:        0.2.0.0+version:        0.2.0.1 synopsis:       utilities to work with Hedgehog generators and `registry` description:    This library provides some functions to extract generators from a "Registry" and make stateful modifications of that Registry to precisely control the generation of data category:       Control
src/Data/Registry/Hedgehog.hs view
@@ -1,53 +1,55 @@-{-# LANGUAGE UndecidableInstances   #-} {-# LANGUAGE AllowAmbiguousTypes   #-} {-# LANGUAGE DataKinds             #-} {-# LANGUAGE PartialTypeSignatures #-}+{-# LANGUAGE UndecidableInstances  #-}  module Data.Registry.Hedgehog (   -- creation / tweaking functions   GenIO , Chooser (..)+, forallS+, forAllT -- re-export of forAllT for convenience purpose since we are working in GenIO+, filterGenS , genFun , genVal , genWith-, tweakGen-, tweakGenS+, modifyGenS , setGen , setGenIO , setGenS , specializeGen , specializeGenIO , specializeGenS+, tweakGen+, tweakGenS , makeNonEmpty , makeNonEmptyS-, forallS-, forAllT -- re-export of forAllT for convenience purpose since we are working in GenIO  -- combinators to compose different types of generators-, pairOf-, tripleOf+, eitherOf+, hashMapOf , listOf , listOfMinMax-, nonEmptyOf-, maybeOf-, eitherOf-, setOf , mapOf+, maybeOf , nonEmptyMapOf-, hashMapOf+, nonEmptyOf+, pairOf+, setOf+, tripleOf  -- cycling values-, setCycleChooserS-, setCycleChooser , choiceChooser , chooseOne+, setCycleChooser+, setCycleChooserS  -- making distinct values-, setDistinctS-, setDistinctForS+, distinct , setDistinct , setDistinctFor-, distinct+, setDistinctForS+, setDistinctS  -- sampling for GenIO generators , sampleIO@@ -65,6 +67,7 @@ import           Data.Set                        as Set (fromList) import           Hedgehog import           Hedgehog.Gen                    as Gen+import           Hedgehog.Internal.Gen           as Gen import           Hedgehog.Internal.Property      (forAllT) import           Hedgehog.Range import           Protolude                       as P@@ -115,6 +118,14 @@ -- | Specialize a generator in a given context specializeGenS :: forall a b m ins out . (Typeable a, Typeable b, Contains (GenIO a) out, MonadState (Registry ins out) m) => Gen b -> m () specializeGenS g = modify (specializeGen @a @b g)++-- | Modify a generator+modifyGenS :: forall a ins out . (Typeable a) => (GenIO a -> GenIO a) -> PropertyT (StateT (Registry ins out) IO) ()+modifyGenS f = modify (tweakUnsafe @(GenIO a) f)++-- | Filter a generator+filterGenS :: forall a ins out . (Typeable a) => (a -> Bool) -> PropertyT (StateT (Registry ins out) IO) ()+filterGenS = modifyGenS . Gen.filterT  -- | Get a value generated from one of the generators in the registry and modify the registry --   using a state monad