Skip to content

Commit

Permalink
Implement all combinators in terms of toGenT / fromGenT
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobstanley committed Apr 28, 2019
1 parent e945326 commit d0d2f60
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 361 deletions.
12 changes: 6 additions & 6 deletions hedgehog-example/src/Test/Example/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ prop_list =
fmap show .
fmap (\xs -> (cond xs, xs))

ts <- forAllWith renderTree (Gen.tree $ genList genInt)
xs0 <- forAll (Gen.liftTree ts)
ts <- forAllWith renderTree (Gen.toTree $ genList genInt)
xs0 <- forAll (Gen.fromTree ts)

assert (cond xs0)

Expand Down Expand Up @@ -79,8 +79,8 @@ prop_state_list =
fmap show .
fmap (\xs -> (cond xs, xs))

ts <- forAllWith renderTree (Gen.tree $ hoist (`Lazy.evalStateT` 0) $ genList genStateInt)
xs0 <- forAll (Gen.liftTree ts)
ts <- forAllWith renderTree (Gen.toTree $ hoist (`Lazy.evalStateT` 0) $ genList genStateInt)
xs0 <- forAll (Gen.fromTree ts)

assert (cond xs0)

Expand Down Expand Up @@ -121,8 +121,8 @@ prop_writer_list =
Tree.render .
fmap (\(ns, ws) -> show (cond ns, ns) ++ " (" ++ renderLog ws ++ ")")

ts <- forAllWith renderTree (Gen.tree . Lazy.runWriterT $ genWriterList genWriterInt)
(xs0, _) <- forAll (Gen.liftTree ts)
ts <- forAllWith renderTree (Gen.toTree . Lazy.runWriterT $ genWriterList genWriterInt)
(xs0, _) <- forAll (Gen.fromTree ts)

assert (cond xs0)

Expand Down
2 changes: 1 addition & 1 deletion hedgehog-quickcheck/src/Hedgehog/Gen/QuickCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Test.QuickCheck.Random as QuickCheck

seedQCGen :: MonadGen m => m QuickCheck.QCGen
seedQCGen =
QuickCheck.mkQCGen <$> Gen.lift (Gen.integral_ Range.constantBounded)
QuickCheck.mkQCGen <$> fromGenT (Gen.integral_ Range.constantBounded)

-- | Create a Hedgehog 'Gen' from a QuickCheck 'QuickCheck.Gen'.
--
Expand Down
4 changes: 2 additions & 2 deletions hedgehog/src/Hedgehog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ module Hedgehog (

, forAll
, forAllWith
, classify
, cover
, discard

, check
Expand Down Expand Up @@ -112,6 +110,8 @@ module Hedgehog (
, evalExceptT

-- * Coverage
, classify
, cover
, label
, collect

Expand Down
5 changes: 1 addition & 4 deletions hedgehog/src/Hedgehog/Gen.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module Hedgehog.Gen (
-- * Combinators
lift

-- ** Shrinking
, shrink
shrink
, prune

-- ** Size
Expand Down
Loading

0 comments on commit d0d2f60

Please sign in to comment.