hedgehog 1.0.3 → 1.0.4
raw patch · 7 files changed
+104/−23 lines, 7 filesdep −faildep −semigroupsdep ~ansi-terminaldep ~bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: fail, semigroups
Dependency ranges changed: ansi-terminal, bytestring
API changes (from Hackage documentation)
- Hedgehog.Internal.Seed: instance System.Random.RandomGen Hedgehog.Internal.Seed.Seed
+ Hedgehog: evalEitherM :: (MonadTest m, Show x, MonadCatch m, HasCallStack) => m (Either x a) -> m a
+ Hedgehog: evalMaybe :: (MonadTest m, Show a, HasCallStack) => Maybe a -> m a
+ Hedgehog: evalMaybeM :: (MonadTest m, Show a, MonadCatch m, HasCallStack) => m (Maybe a) -> m a
+ Hedgehog.Internal.Property: evalEitherM :: (MonadTest m, Show x, MonadCatch m, HasCallStack) => m (Either x a) -> m a
+ Hedgehog.Internal.Property: evalMaybe :: (MonadTest m, Show a, HasCallStack) => Maybe a -> m a
+ Hedgehog.Internal.Property: evalMaybeM :: (MonadTest m, Show a, MonadCatch m, HasCallStack) => m (Maybe a) -> m a
+ Hedgehog.Internal.Seed: instance System.Random.Internal.RandomGen Hedgehog.Internal.Seed.Seed
- Hedgehog: Command :: (state Symbolic -> Maybe (gen (input Symbolic))) -> (input Concrete -> m output) -> [Callback input output state] -> Command gen m
+ Hedgehog: Command :: (state Symbolic -> Maybe (gen (input Symbolic))) -> (input Concrete -> m output) -> [Callback input output state] -> Command gen m (state :: (* -> *) -> *)
- Hedgehog: [commandCallbacks] :: Command gen m -> [Callback input output state]
+ Hedgehog: [commandCallbacks] :: Command gen m (state :: (* -> *) -> *) -> [Callback input output state]
- Hedgehog: [commandExecute] :: Command gen m -> input Concrete -> m output
+ Hedgehog: [commandExecute] :: Command gen m (state :: (* -> *) -> *) -> input Concrete -> m output
- Hedgehog: [commandGen] :: Command gen m -> state Symbolic -> Maybe (gen (input Symbolic))
+ Hedgehog: [commandGen] :: Command gen m (state :: (* -> *) -> *) -> state Symbolic -> Maybe (gen (input Symbolic))
- Hedgehog.Internal.Gen: [:.] :: a -> Vec n a -> Vec ( 'S n) a
+ Hedgehog.Internal.Gen: [:.] :: a -> Vec n a -> Vec ('S n) a
- Hedgehog.Internal.Gen: [Nil] :: Vec 'Z a
+ Hedgehog.Internal.Gen: [Nil] :: Vec 'Z a
- Hedgehog.Internal.Prelude: (!!) :: () => [a] -> Int -> a
+ Hedgehog.Internal.Prelude: (!!) :: [a] -> Int -> a
- Hedgehog.Internal.Prelude: ($!) :: () => (a -> b) -> a -> b
+ Hedgehog.Internal.Prelude: ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Hedgehog.Internal.Prelude: ($) :: () => (a -> b) -> a -> b
+ Hedgehog.Internal.Prelude: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Hedgehog.Internal.Prelude: (++) :: () => [a] -> [a] -> [a]
+ Hedgehog.Internal.Prelude: (++) :: [a] -> [a] -> [a]
- Hedgehog.Internal.Prelude: (.) :: () => (b -> c) -> (a -> b) -> a -> c
+ Hedgehog.Internal.Prelude: (.) :: (b -> c) -> (a -> b) -> a -> c
- Hedgehog.Internal.Prelude: asTypeOf :: () => a -> a -> a
+ Hedgehog.Internal.Prelude: asTypeOf :: a -> a -> a
- Hedgehog.Internal.Prelude: break :: () => (a -> Bool) -> [a] -> ([a], [a])
+ Hedgehog.Internal.Prelude: break :: (a -> Bool) -> [a] -> ([a], [a])
- Hedgehog.Internal.Prelude: const :: () => a -> b -> a
+ Hedgehog.Internal.Prelude: const :: a -> b -> a
- Hedgehog.Internal.Prelude: curry :: () => ((a, b) -> c) -> a -> b -> c
+ Hedgehog.Internal.Prelude: curry :: ((a, b) -> c) -> a -> b -> c
- Hedgehog.Internal.Prelude: cycle :: () => [a] -> [a]
+ Hedgehog.Internal.Prelude: cycle :: [a] -> [a]
- Hedgehog.Internal.Prelude: drop :: () => Int -> [a] -> [a]
+ Hedgehog.Internal.Prelude: drop :: Int -> [a] -> [a]
- Hedgehog.Internal.Prelude: dropWhile :: () => (a -> Bool) -> [a] -> [a]
+ Hedgehog.Internal.Prelude: dropWhile :: (a -> Bool) -> [a] -> [a]
- Hedgehog.Internal.Prelude: either :: () => (a -> c) -> (b -> c) -> Either a b -> c
+ Hedgehog.Internal.Prelude: either :: (a -> c) -> (b -> c) -> Either a b -> c
- Hedgehog.Internal.Prelude: error :: HasCallStack => [Char] -> a
+ Hedgehog.Internal.Prelude: error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
- Hedgehog.Internal.Prelude: errorWithoutStackTrace :: () => [Char] -> a
+ Hedgehog.Internal.Prelude: errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
- Hedgehog.Internal.Prelude: fail :: Monad m => String -> m a
+ Hedgehog.Internal.Prelude: fail :: MonadFail m => String -> m a
- Hedgehog.Internal.Prelude: flip :: () => (a -> b -> c) -> b -> a -> c
+ Hedgehog.Internal.Prelude: flip :: (a -> b -> c) -> b -> a -> c
- Hedgehog.Internal.Prelude: fst :: () => (a, b) -> a
+ Hedgehog.Internal.Prelude: fst :: (a, b) -> a
- Hedgehog.Internal.Prelude: head :: () => [a] -> a
+ Hedgehog.Internal.Prelude: head :: [a] -> a
- Hedgehog.Internal.Prelude: id :: () => a -> a
+ Hedgehog.Internal.Prelude: id :: a -> a
- Hedgehog.Internal.Prelude: infixl 6 -
+ Hedgehog.Internal.Prelude: infixl 6 +
- Hedgehog.Internal.Prelude: init :: () => [a] -> [a]
+ Hedgehog.Internal.Prelude: init :: [a] -> [a]
- Hedgehog.Internal.Prelude: ioError :: () => IOError -> IO a
+ Hedgehog.Internal.Prelude: ioError :: IOError -> IO a
- Hedgehog.Internal.Prelude: iterate :: () => (a -> a) -> a -> [a]
+ Hedgehog.Internal.Prelude: iterate :: (a -> a) -> a -> [a]
- Hedgehog.Internal.Prelude: last :: () => [a] -> a
+ Hedgehog.Internal.Prelude: last :: [a] -> a
- Hedgehog.Internal.Prelude: maybe :: () => b -> (a -> b) -> Maybe a -> b
+ Hedgehog.Internal.Prelude: maybe :: b -> (a -> b) -> Maybe a -> b
- Hedgehog.Internal.Prelude: readParen :: () => Bool -> ReadS a -> ReadS a
+ Hedgehog.Internal.Prelude: readParen :: Bool -> ReadS a -> ReadS a
- Hedgehog.Internal.Prelude: repeat :: () => a -> [a]
+ Hedgehog.Internal.Prelude: repeat :: a -> [a]
- Hedgehog.Internal.Prelude: replicate :: () => Int -> a -> [a]
+ Hedgehog.Internal.Prelude: replicate :: Int -> a -> [a]
- Hedgehog.Internal.Prelude: reverse :: () => [a] -> [a]
+ Hedgehog.Internal.Prelude: reverse :: [a] -> [a]
- Hedgehog.Internal.Prelude: scanl :: () => (b -> a -> b) -> b -> [a] -> [b]
+ Hedgehog.Internal.Prelude: scanl :: (b -> a -> b) -> b -> [a] -> [b]
- Hedgehog.Internal.Prelude: scanl1 :: () => (a -> a -> a) -> [a] -> [a]
+ Hedgehog.Internal.Prelude: scanl1 :: (a -> a -> a) -> [a] -> [a]
- Hedgehog.Internal.Prelude: scanr :: () => (a -> b -> b) -> b -> [a] -> [b]
+ Hedgehog.Internal.Prelude: scanr :: (a -> b -> b) -> b -> [a] -> [b]
- Hedgehog.Internal.Prelude: scanr1 :: () => (a -> a -> a) -> [a] -> [a]
+ Hedgehog.Internal.Prelude: scanr1 :: (a -> a -> a) -> [a] -> [a]
- Hedgehog.Internal.Prelude: seq :: () => a -> b -> b
+ Hedgehog.Internal.Prelude: seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b
- Hedgehog.Internal.Prelude: snd :: () => (a, b) -> b
+ Hedgehog.Internal.Prelude: snd :: (a, b) -> b
- Hedgehog.Internal.Prelude: span :: () => (a -> Bool) -> [a] -> ([a], [a])
+ Hedgehog.Internal.Prelude: span :: (a -> Bool) -> [a] -> ([a], [a])
- Hedgehog.Internal.Prelude: splitAt :: () => Int -> [a] -> ([a], [a])
+ Hedgehog.Internal.Prelude: splitAt :: Int -> [a] -> ([a], [a])
- Hedgehog.Internal.Prelude: tail :: () => [a] -> [a]
+ Hedgehog.Internal.Prelude: tail :: [a] -> [a]
- Hedgehog.Internal.Prelude: take :: () => Int -> [a] -> [a]
+ Hedgehog.Internal.Prelude: take :: Int -> [a] -> [a]
- Hedgehog.Internal.Prelude: takeWhile :: () => (a -> Bool) -> [a] -> [a]
+ Hedgehog.Internal.Prelude: takeWhile :: (a -> Bool) -> [a] -> [a]
- Hedgehog.Internal.Prelude: uncurry :: () => (a -> b -> c) -> (a, b) -> c
+ Hedgehog.Internal.Prelude: uncurry :: (a -> b -> c) -> (a, b) -> c
- Hedgehog.Internal.Prelude: undefined :: HasCallStack => a
+ Hedgehog.Internal.Prelude: undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
- Hedgehog.Internal.Prelude: until :: () => (a -> Bool) -> (a -> a) -> a -> a
+ Hedgehog.Internal.Prelude: until :: (a -> Bool) -> (a -> a) -> a -> a
- Hedgehog.Internal.Prelude: unzip :: () => [(a, b)] -> ([a], [b])
+ Hedgehog.Internal.Prelude: unzip :: [(a, b)] -> ([a], [b])
- Hedgehog.Internal.Prelude: unzip3 :: () => [(a, b, c)] -> ([a], [b], [c])
+ Hedgehog.Internal.Prelude: unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- Hedgehog.Internal.Prelude: zip :: () => [a] -> [b] -> [(a, b)]
+ Hedgehog.Internal.Prelude: zip :: [a] -> [b] -> [(a, b)]
- Hedgehog.Internal.Prelude: zip3 :: () => [a] -> [b] -> [c] -> [(a, b, c)]
+ Hedgehog.Internal.Prelude: zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- Hedgehog.Internal.Prelude: zipWith :: () => (a -> b -> c) -> [a] -> [b] -> [c]
+ Hedgehog.Internal.Prelude: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- Hedgehog.Internal.Prelude: zipWith3 :: () => (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
+ Hedgehog.Internal.Prelude: zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- Hedgehog.Internal.Source: callStack :: HasCallStack -> CallStack
+ Hedgehog.Internal.Source: callStack :: HasCallStack => CallStack
- Hedgehog.Internal.Source: withFrozenCallStack :: HasCallStack => (HasCallStack -> a) -> a
+ Hedgehog.Internal.Source: withFrozenCallStack :: HasCallStack => (HasCallStack => a) -> a
- Hedgehog.Internal.State: Action :: input Symbolic -> Symbolic output -> (input Concrete -> m output) -> (state Symbolic -> input Symbolic -> Bool) -> (forall v. Ord1 v => state v -> input v -> Var output v -> state v) -> (state Concrete -> state Concrete -> input Concrete -> output -> Test ()) -> Action m
+ Hedgehog.Internal.State: Action :: input Symbolic -> Symbolic output -> (input Concrete -> m output) -> (state Symbolic -> input Symbolic -> Bool) -> (forall v. Ord1 v => state v -> input v -> Var output v -> state v) -> (state Concrete -> state Concrete -> input Concrete -> output -> Test ()) -> Action m (state :: (* -> *) -> *)
- Hedgehog.Internal.State: Command :: (state Symbolic -> Maybe (gen (input Symbolic))) -> (input Concrete -> m output) -> [Callback input output state] -> Command gen m
+ Hedgehog.Internal.State: Command :: (state Symbolic -> Maybe (gen (input Symbolic))) -> (input Concrete -> m output) -> [Callback input output state] -> Command gen m (state :: (* -> *) -> *)
- Hedgehog.Internal.State: [actionEnsure] :: Action m -> state Concrete -> state Concrete -> input Concrete -> output -> Test ()
+ Hedgehog.Internal.State: [actionEnsure] :: Action m (state :: (* -> *) -> *) -> state Concrete -> state Concrete -> input Concrete -> output -> Test ()
- Hedgehog.Internal.State: [actionExecute] :: Action m -> input Concrete -> m output
+ Hedgehog.Internal.State: [actionExecute] :: Action m (state :: (* -> *) -> *) -> input Concrete -> m output
- Hedgehog.Internal.State: [actionInput] :: Action m -> input Symbolic
+ Hedgehog.Internal.State: [actionInput] :: Action m (state :: (* -> *) -> *) -> input Symbolic
- Hedgehog.Internal.State: [actionOutput] :: Action m -> Symbolic output
+ Hedgehog.Internal.State: [actionOutput] :: Action m (state :: (* -> *) -> *) -> Symbolic output
- Hedgehog.Internal.State: [actionRequire] :: Action m -> state Symbolic -> input Symbolic -> Bool
+ Hedgehog.Internal.State: [actionRequire] :: Action m (state :: (* -> *) -> *) -> state Symbolic -> input Symbolic -> Bool
- Hedgehog.Internal.State: [actionUpdate] :: Action m -> forall v. Ord1 v => state v -> input v -> Var output v -> state v
+ Hedgehog.Internal.State: [actionUpdate] :: Action m (state :: (* -> *) -> *) -> forall v. Ord1 v => state v -> input v -> Var output v -> state v
- Hedgehog.Internal.State: [commandCallbacks] :: Command gen m -> [Callback input output state]
+ Hedgehog.Internal.State: [commandCallbacks] :: Command gen m (state :: (* -> *) -> *) -> [Callback input output state]
- Hedgehog.Internal.State: [commandExecute] :: Command gen m -> input Concrete -> m output
+ Hedgehog.Internal.State: [commandExecute] :: Command gen m (state :: (* -> *) -> *) -> input Concrete -> m output
- Hedgehog.Internal.State: [commandGen] :: Command gen m -> state Symbolic -> Maybe (gen (input Symbolic))
+ Hedgehog.Internal.State: [commandGen] :: Command gen m (state :: (* -> *) -> *) -> state Symbolic -> Maybe (gen (input Symbolic))
Files
- CHANGELOG.md +48/−0
- hedgehog.cabal +4/−10
- src/Hedgehog.hs +4/−1
- src/Hedgehog/Internal/Gen.hs +4/−1
- src/Hedgehog/Internal/Property.hs +32/−5
- src/Hedgehog/Internal/Range.hs +7/−1
- src/Hedgehog/Internal/Tripping.hs +5/−5
CHANGELOG.md view
@@ -1,5 +1,18 @@+## Version 1.0.4 (2020-12-11)++- Bump ansi-terminal to 0.11 ([#394][394], [@mpilgrem][mpilgrem])+- Clean up hedgehog.cabal for GHC 8.0+ ([#391][391], [@felixonmars][felixonmars])+- Bump random to 1.2 ([#396][396], [@felixonmars][felixonmars])+- Improve the distribution of `Range.scaleLinear` ([#405][405], [@jonfowler][jonfowler] / [@moodmosaic][moodmosaic])+- Change `Gen.frequency` generator immediately shrink ([#406][406], [@ocharles][ocharles] / [@HuwCampbell][HuwCampbell])+- Add `Property.evalMaybe`, `Property.evalMaybeM` and `Property.evalEitherM` ([#381][381], [@markus1189][markus1189] / [@moodmosaic][moodmosaic])+- Bump QuickCheck to 2.14 ([#409][409], [@lehins][lehins])+- Bump bytestring to 0.11 ([#408][408], [@Bodigrim][Bodigrim])+- Minor Haddock formatting improvments ([#398][398], [@sshine][sshine] / [@moodmosaic][moodmosaic])+ ## Version 1.0.3 (2020-06-26) +- Bump cabal-version to 1.10 ([#390][390], [@moodmosaic][moodmosaic]) - Don't swallow errors if we can't find the source file ([#387][387], [@HuwCampbell][HuwCampbell]) - Add `Property.evalNF` ([#384][384], [@dcastro][dcastro]) - Add `Gen.either` and `Gen.either_` ([#382][382], [@dcastro][dcastro])@@ -190,13 +203,48 @@ https://github.com/kquick [dcastro]: https://github.com/dcastro+[Bodigrim]:+ https://github.com/Bodigrim+[lehins]:+ https://github.com/lehins+[markus1189]:+ https://github.com/markus1189+[ocharles]:+ https://github.com/ocharles+[jonfowler]:+ https://github.com/jonfowler+[felixonmars]:+ https://github.com/felixonmars+[mpilgrem]:+ https://github.com/mpilgrem ++[409]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/409+[408]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/408+[406]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/406+[405]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/405+[398]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/398+[396]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/396+[394]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/394+[391]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/391+[390]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/390 [387]: https://github.com/hedgehogqa/haskell-hedgehog/pull/387 [384]: https://github.com/hedgehogqa/haskell-hedgehog/pull/384 [382]: https://github.com/hedgehogqa/haskell-hedgehog/pull/382+[381]:+ https://github.com/hedgehogqa/haskell-hedgehog/pull/381 [376]: https://github.com/hedgehogqa/haskell-hedgehog/pull/376 [366]:
hedgehog.cabal view
@@ -1,4 +1,4 @@-version: 1.0.3+version: 1.0.4 name: hedgehog@@ -51,25 +51,23 @@ build-depends: -- GHC 8.0.1 / base-4.9.0.0 (May 2016) base >= 4.9 && < 5- , ansi-terminal >= 0.6 && < 0.11+ , ansi-terminal >= 0.6 && < 0.12 , async >= 2.0 && < 2.3- , bytestring >= 0.10 && < 0.11+ , bytestring >= 0.10 && < 0.12 , concurrent-output >= 1.7 && < 1.11 , containers >= 0.4 && < 0.7 , deepseq >= 1.1.0.0 && < 1.5 , directory >= 1.2 && < 1.4 , erf >= 2.0 && < 2.1 , exceptions >= 0.7 && < 0.11- , fail >= 4.9 && < 5 , lifted-async >= 0.7 && < 0.11 , mmorph >= 1.0 && < 1.2 , monad-control >= 1.0 && < 1.1 , mtl >= 2.1 && < 2.3 , pretty-show >= 1.6 && < 1.11 , primitive >= 0.6 && < 0.8- , random >= 1.1 && < 1.2+ , random >= 1.1 && < 1.3 , resourcet >= 1.1 && < 1.3- , semigroups >= 0.16 && < 0.20 , stm >= 2.4 && < 2.6 , template-haskell >= 2.10 && < 2.17 , text >= 1.1 && < 1.3@@ -81,9 +79,6 @@ ghc-options: -Wall - if impl(ghc >= 8.0)- ghc-options: -Wnoncanonical-monad-instances- hs-source-dirs: src @@ -148,7 +143,6 @@ , mmorph >= 1.0 && < 1.2 , mtl >= 2.1 && < 2.3 , pretty-show >= 1.6 && < 1.11- , semigroups >= 0.16 && < 0.20 , text >= 1.1 && < 1.3 , transformers >= 0.3 && < 0.6
src/Hedgehog.hs view
@@ -112,7 +112,10 @@ , evalM , evalIO , evalEither+ , evalEitherM , evalExceptT+ , evalMaybe+ , evalMaybeM -- * Coverage , LabelName@@ -166,7 +169,7 @@ import Hedgehog.Internal.Property (discard, failure, success) import Hedgehog.Internal.Property (DiscardLimit, withDiscards) import Hedgehog.Internal.Property (eval, evalNF, evalM, evalIO)-import Hedgehog.Internal.Property (evalEither, evalExceptT)+import Hedgehog.Internal.Property (evalEither, evalEitherM, evalExceptT, evalMaybe, evalMaybeM) import Hedgehog.Internal.Property (footnote, footnoteShow) import Hedgehog.Internal.Property (forAll, forAllWith) import Hedgehog.Internal.Property (LabelName, MonadTest(..))
src/Hedgehog/Internal/Gen.hs view
@@ -1190,10 +1190,13 @@ else pick (n - k) xs + iis =+ scanl1 (+) (fmap fst xs0)+ total = sum (fmap fst xs0) - n <- integral $ Range.constant 1 total+ n <- shrink (\n -> takeWhile (< n) iis) $ integral_ $ Range.constant 1 total pick n xs0 -- | Modifies combinators which choose from a list of generators, like 'choice'
src/Hedgehog/Internal/Property.hs view
@@ -77,7 +77,10 @@ , evalM , evalIO , evalEither+ , evalEitherM , evalExceptT+ , evalMaybe+ , evalMaybeM -- * Coverage , Coverage(..)@@ -126,7 +129,7 @@ import Control.Applicative (Alternative(..)) import Control.DeepSeq (NFData, rnf)-import Control.Monad (MonadPlus(..))+import Control.Monad (MonadPlus(..), (<=<)) import Control.Monad.Base (MonadBase(..)) import Control.Monad.Catch (MonadThrow(..), MonadCatch(..)) import Control.Monad.Catch (SomeException(..), displayException)@@ -754,10 +757,10 @@ -- diff x (<=) 'r' -- @ ----- /This function behaves like the unix `diff` tool, which gives a `0` exit/--- /code if the compared files are identical, or a `1` exit code code/--- /otherwise. Like unix `diff`, if the arguments fail the comparison, a diff/--- /is shown./+-- This function behaves like the unix @diff@ tool, which gives a 0 exit+-- code if the compared files are identical, or a 1 exit code code+-- otherwise. Like unix @diff@, if the arguments fail the comparison, a+-- /diff is shown. -- diff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> (a -> b -> Bool) -> b -> m () diff x op y = do@@ -831,12 +834,36 @@ Right x -> pure x +-- | Fails the test if the action throws an exception, or if the+-- 'Either' is 'Left', otherwise returns the value in the 'Right'.+--+evalEitherM :: (MonadTest m, Show x, MonadCatch m, HasCallStack) => m (Either x a) -> m a+evalEitherM =+ evalEither <=< evalM+ -- | Fails the test if the 'ExceptT' is 'Left', otherwise returns the value in -- the 'Right'. -- evalExceptT :: (MonadTest m, Show x, HasCallStack) => ExceptT x m a -> m a evalExceptT m = withFrozenCallStack evalEither =<< runExceptT m++-- | Fails the test if the 'Maybe' is 'Nothing', otherwise returns the value in+-- the 'Just'.+--+evalMaybe :: (MonadTest m, Show a, HasCallStack) => Maybe a -> m a+evalMaybe = \case+ Nothing ->+ withFrozenCallStack $ failWith Nothing "the value was Nothing"+ Just x ->+ pure x++-- | Fails the test if the action throws an exception, or if the+-- 'Maybe' is 'Nothing', otherwise returns the value in the 'Just'.+--+evalMaybeM :: (MonadTest m, Show a, MonadCatch m, HasCallStack) => m (Maybe a) -> m a+evalMaybeM =+ evalMaybe <=< evalM ------------------------------------------------------------------------ -- PropertyT
src/Hedgehog/Internal/Range.hs view
@@ -305,8 +305,14 @@ n = toInteger n0 + -- @rng@ has magnitude 1 bigger than the biggest diff+ -- i.e. it specifies the range the diff can be in [0,rng)+ -- with the upper bound being exclusive.+ rng =+ n - z + signum (n - z)+ diff =- ((n - z) * fromIntegral sz) `quot` 99+ (rng * fromIntegral sz) `quot` 100 in fromInteger $ z + diff
src/Hedgehog/Internal/Tripping.hs view
@@ -10,12 +10,12 @@ -- | Test that a pair of encode / decode functions are compatible. ----- Given a printer from some type 'a -> b', and a parser with a--- potential failure case 'b -> f a'. Ensure that a valid 'a' round--- trips through the "print" and "parse" to yield the same 'a'.+-- Given a printer from some type @a -> b@, and a parser with a+-- potential failure case @b -> f a@. Ensure that a valid @a@ round+-- trips through the "print" and "parse" to yield the same @a@. ----- For example, types __should__ have tripping 'Read' and 'Show'--- instances.+-- For example, types /should/ have tripping 'Read' and 'Show'+-- instances: -- -- @ -- trippingShowRead :: (Show a, Read a, Eq a, MonadTest m) => a -> m ()