Use QuickCheck generators in Hedgehog and vice versa.


Version on this page:0.1.1@rev:2
LTS Haskell 22.29:0.1.1@rev:7
Stackage Nightly 2024-07-19:0.1.1@rev:7
Latest on Hackage:0.1.1@rev:7

See all snapshots hedgehog-quickcheck appears in

BSD-3-Clause licensed by Jacob Stanley
Maintained by Jacob Stanley
This version can be pinned in stack with:hedgehog-quickcheck-0.1.1@sha256:b765721ce783c58ca74d07eb60ef096e8f53e080b1ea8af491242dc83c66f1d8,1640

Module documentation for 0.1.1

hedgehog-quickcheck Hackage

Hedgehog will eat all your bugs.

Use QuickCheck generators in Hedgehog and vice versa.


The Hedgehog.Gen.QuickCheck module allows the use of QuickCheck generators inside Hedgehog.

{-# LANGUAGE TemplateHaskell #-}

import           Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Gen.QuickCheck as Gen
import qualified Hedgehog.Range as Range

Once you have your imports set up, you can write a property which mixes QuickCheck and Hedgehog generators together:

prop_reverse :: Property
prop_reverse =
  property $ do
    xs <- forAll $ Gen.list (Range.linear 0 100) (Gen.arbitrary :: Gen Char)
    reverse (reverse xs) === xs

And add the Template Haskell splice which will discover your properties:

tests :: IO Bool
tests =
  checkParallel $$(discover)

You can then load the module in GHCi, and run it:

λ tests
━━━ Test.Example ━━━
  ✓ prop_reverse passed 100 tests.


Version 0.1 (2017-07-16)