A property test, along with some configurable limits like how many times to run the test.
Modulehedgehog-1.7Haskell2010
Hedgehog
This module includes almost everything you need to get started writing property tests with Hedgehog.
It is designed to be used alongside Hedgehog.Gen and Hedgehog.Range, which should be imported qualified. You also need to enable Template Haskell so the Hedgehog test runner can find your properties.
{-# LANGUAGE TemplateHaskell #-}
import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as RangeOnce you have your imports set up, you can write a simple property:
prop_reverse :: Property
prop_reverse =
property $ do
xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
reverse (reverse xs) === xsAnd add the Template Haskell splice which will discover your properties:
tests :: IO Bool
tests =
checkParallel $$(discover)If you prefer to avoid macros, you can specify the group of properties to run manually instead:
{-# LANGUAGE OverloadedStrings #-}
tests :: IO Bool
tests =
checkParallel $ Group "Test.Example" [
("prop_reverse", prop_reverse)
]You can then load the module in GHCi, and run it:
λ tests
━━━ Test.Example ━━━
✓ prop_reverse passed 100 tests.- 29 types
- 8 classes
- 50 values
- Packagehedgehog-1.7
- Exports88
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceHedgehog.hs
Properties
30 declarationsThe property monad transformer allows both the generation of test inputs and the assertion of expectations.
Instances23MonadTrans, MonadTransDistributive, MFunctor, MonadError, MonadReader, MonadState, …
MonadTrans PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransDistributive PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMFunctor PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadError e m => MonadError e (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadReader r m => MonadReader r (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadState s m => MonadState s (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBase b m => MonadBase b (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Monad (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyFunctor m => Functor (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadFail (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Applicative (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadPlus m => Alternative (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadPlus m => MonadPlus (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadIO m => MonadIO (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadCatch m => MonadCatch (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadThrow m => MonadThrow (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyPrimMonad m => PrimMonad (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadResource m => MonadResource (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype PrimState (PropertyT m) = PrimState mDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StM (PropertyT m) a = StM (TestT (GenT m)) aDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype Transformer t PropertyT m = (Transformer t GenT m, Transformer t TestT (GenT m))Defined in hedgehog-1.7 · Hedgehog.Internal.Property
A named collection of property tests.
Constructors
GroupgroupName :: !GroupNamegroupProperties :: ![(PropertyName, Property)]
The name of a property.
Should be constructed using OverloadedStrings:
"apples" :: PropertyName
Instances6Eq, Ord, Show, IsString, Semigroup, Lift
Eq PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The name of a group of properties.
Should be constructed using OverloadedStrings:
"fruit" :: GroupName
Instances6Eq, Ord, Show, IsString, Semigroup, Lift
Eq GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Creates a property with the default configuration.
Lift a test in to a property.
Because both TestT and PropertyT have MonadTest instances, this function is not often required. It can however be useful for writing functions directly in TestT and thus gaining a MonadTransControl instance at the expense of not being able to generate additional inputs using forAll.
An example where this is useful is parallel state machine testing, as executeParallel requires MonadBaseControl IO in order to be able to spawn threads in MonadTest.
Generates a random input for the test by running the provided generator.
Discards the current test entirely.
Check a property.
Check a property using a specific size and seed.
Discover all the properties in a module.
Functions starting with prop_ are assumed to be properties.
Check a group of properties in parallel.
Warning: although this check function runs tests faster than checkSequential, it should be noted that it may cause problems with properties that are not self-contained. For example, if you have a group of tests which all use the same database table, you may find that they interfere with each other when being run in parallel.
Using Template Haskell for property discovery:
tests :: IO Bool
tests =
checkParallel $$(discover)With manually specified properties:
tests :: IO Bool
tests =
checkParallel $ Group "Test.Example" [
("prop_reverse", prop_reverse)
]Check a group of properties sequentially.
Using Template Haskell for property discovery:
tests :: IO Bool
tests =
checkSequential $$(discover)With manually specified properties:
tests :: IO Bool
tests =
checkSequential $ Group "Test.Example" [
("prop_reverse", prop_reverse)
]The acceptable occurrence of false positives
Example, Confidence 10^9 would mean that you'd accept a false positive
for 1 in 10^9 tests.
Instances5Eq, Num, Ord, Show, Lift
Eq ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Make sure that the result is statistically significant in accordance to the passed Confidence
Set the number of times a property should be executed before it is considered successful.
If you have a test that does not involve any generators and thus does not
need to run repeatedly, you can use withTests 1 to define a property that
will only be checked once.
The number of successful tests that need to be run before a property test is considered successful.
Can be constructed using numeric literals:
200 :: TestLimit
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Set the number of times a property is allowed to discard before the test runner gives up.
The number of discards to allow before giving up.
Can be constructed using numeric literals:
10000 :: DiscardLimit
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Set the number of times a property is allowed to shrink before the test runner gives up and prints the counterexample.
The number of shrinks to try before giving up on shrinking.
Can be constructed using numeric literals:
1000 :: ShrinkLimit
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Set the number of times a property will be executed for each shrink before the test runner gives up and tries a different shrink. See ShrinkRetries for more information.
The number of times to re-run a test during shrinking. This is useful if you are testing something which fails non-deterministically and you want to increase the change of getting a good shrink.
If you are doing parallel state machine testing, you should probably set
shrink retries to something like 10. This will mean that during
shrinking, a parallel test case requires 10 successful runs before it is
passes and we try a different shrink.
Can be constructed using numeric literals:
0 :: ShrinkRetries
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Set the target that a property will skip to before it starts to run.
Where to start running a property's tests.
Instances5Eq, Ord, Show, IsString, Lift
Eq SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyWe use this instance to support usage like
withSkip "3:aB"It throws an error if the input is not a valid compressed Skip.
Lift SkipDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Generating Test Data
6 declarationsGenerator for random values of a.
Monad transformer which can generate random values of a.
Instances28MonadTrans, MMonad, MonadTransDistributive, MFunctor, MonadError, MonadReader, …
MonadTrans GenTDefined in hedgehog-1.7 · Hedgehog.Internal.GenMMonad GenTDefined in hedgehog-1.7 · Hedgehog.Internal.GenMonadTransDistributive GenTDefined in hedgehog-1.7 · Hedgehog.Internal.GenMFunctor GenTDefined in hedgehog-1.7 · Hedgehog.Internal.GenMonadError e m => MonadError e (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadReader r m => MonadReader r (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadState s m => MonadState s (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadWriter w m => MonadWriter w (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadBase b m => MonadBase b (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadBaseControl b m => MonadBaseControl b (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => Monad (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenFunctor m => Functor (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => MonadFail (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => Applicative (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => Alternative (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => MonadPlus (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadIO m => MonadIO (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadCatch m => MonadCatch (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadThrow m => MonadThrow (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenPrimMonad m => PrimMonad (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadResource m => MonadResource (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonad m => MonadGen (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.Gen(Monad m, Semigroup a) => Semigroup (GenT m a)Defined in hedgehog-1.7 · Hedgehog.Internal.Gen(Monad m, Monoid a) => Monoid (GenT m a)Defined in hedgehog-1.7 · Hedgehog.Internal.Gentype PrimState (GenT m) = PrimState mDefined in hedgehog-1.7 · Hedgehog.Internal.Gentype StM (GenT m) a = StM (ReaderT Size (ReaderT Seed (TreeT (MaybeT m)))) aDefined in hedgehog-1.7 · Hedgehog.Internal.Gentype GenBase (GenT m) = mDefined in hedgehog-1.7 · Hedgehog.Internal.Gentype Transformer t GenT m = (Monad (t (GenT m)), Transformer t MaybeT m, Transformer t TreeT (MaybeT m))Defined in hedgehog-1.7 · Hedgehog.Internal.Gen
Class of monads which can generate input data for tests.
Instances9MonadGen, …
Monad m => MonadGen (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (MaybeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (ExceptT x m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (IdentityT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (ReaderT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (StateT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadGen m => MonadGen (StateT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.Gen(MonadGen m, Monoid w) => MonadGen (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.Gen(MonadGen m, Monoid w) => MonadGen (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.Gen
Tests are parameterized by the size of the randomly-generated data. The meaning of a Size value depends on the particular generator used, but it must always be a number between 0 and 99 inclusive.
Instances8Enum, Eq, Integral, Num, Ord, Read, …
Enum SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeEq SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeIntegral SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeNum SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeOrd SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeRead SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeReal SizeDefined in hedgehog-1.7 · Hedgehog.Internal.RangeShow SizeDefined in hedgehog-1.7 · Hedgehog.Internal.Range
A splittable random number generator.
Instances6Eq, Ord, Read, Show, RandomGen, Lift
Eq SeedDefined in hedgehog-1.7 · Hedgehog.Internal.SeedOrd SeedDefined in hedgehog-1.7 · Hedgehog.Internal.SeedRead SeedDefined in hedgehog-1.7 · Hedgehog.Internal.SeedShow SeedDefined in hedgehog-1.7 · Hedgehog.Internal.SeedRandomGen SeedDefined in hedgehog-1.7 · Hedgehog.Internal.SeedLift SeedDefined in hedgehog-1.7 · Hedgehog.Internal.Seed
Tests
23 declarationsA test monad allows the assertion of expectations.
A test monad transformer allows the assertion of expectations.
Instances23MonadTrans, MonadTransControl, MonadTransDistributive, MFunctor, MonadError, MonadReader, …
MonadTrans TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransControl TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransDistributive TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMFunctor TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadError e m => MonadError e (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadReader r m => MonadReader r (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadState s m => MonadState s (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBase b m => MonadBase b (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Monad (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyFunctor m => Functor (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadFail (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Applicative (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadIO m => MonadIO (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadCatch m => MonadCatch (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadThrow m => MonadThrow (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyPrimMonad m => PrimMonad (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadResource m => MonadResource (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype PrimState (TestT m) = PrimState mDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StM (TestT m) a = ComposeSt TestT m aDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StT TestT a = (Either Failure a, Journal)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype Transformer t TestT m = (Transformer t (WriterT Journal) m, Transformer t (ExceptT Failure) (WriterT Journal m))Defined in hedgehog-1.7 · Hedgehog.Internal.Property
Instances14MonadTest, …
Monad m => MonadTest (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ResourceT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (MaybeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ExceptT x m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (IdentityT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ReaderT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (StateT s m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (StateT s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ContT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (RWST r w s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (RWST r w s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property
Annotates the source code with a message that might be useful for debugging a test failure.
Annotates the source code with a value that might be useful for debugging a test failure.
Logs a message to be displayed as additional information in the footer of the failure report.
Logs a value to be displayed as additional information in the footer of the failure report.
Another name for pure ().
Causes a test to fail.
Fails the test if the condition provided is False.
Fails the test and shows a git-like diff if the comparison operation evaluates to False when applied to its arguments.
The comparison function is the second argument, which may be counter-intuitive to Haskell programmers. However, it allows operators to be written infix for easy reading:
diff y (<) 87
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.
Fails the test if the two arguments provided are not equal.
Fails the test if the two arguments provided are equal.
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.
For example, types should have tripping Read and Show instances:
trippingShowRead :: (Show a, Read a, Eq a, MonadTest m) => a -> m ()
trippingShowRead a = tripping a show readEither
Fails the test if the value throws an exception when evaluated to weak head normal form (WHNF).
Fails the test if the value throws an exception when evaluated to normal form (NF).
Fails the test if the action throws an exception.
The benefit of using this over simply letting the exception bubble up is that the location of the closest evalM will be shown in the output.
Coverage
5 declarationsThe name of a classifier.
Should be constructed using OverloadedStrings:
"apples" :: LabelName
Instances6Eq, Ord, Show, IsString, Semigroup, Monoid
Eq LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonoid LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Records the proportion of tests which satisfy a given condition.
prop_with_classifier :: Property
prop_with_classifier =
property $ do
xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
for_ xs $ \x -> do
classify "newborns" $ x == 0
classify "children" $ x > 0 && x < 13
classify "teens" $ x > 12 && x < 20
Require a certain percentage of the tests to be covered by the classifier.
prop_with_coverage :: Property
prop_with_coverage =
property $ do
match <- forAll Gen.bool
cover 30 "True" $ match
cover 30 "False" $ not match
The example above requires a minimum of 30% coverage for both classifiers. If these requirements are not met, it will fail the test.
Add a label for each test run. It produces a table showing the percentage of test runs that produced each label.
State Machine Tests
13 declarationsThe specification for the expected behaviour of an Action. These are used to generate sequences of actions to test.
This is the main type you will use when writing state machine
tests. gen is usually an instance of MonadGen, and m is usually
an instance of MonadTest. These constraints appear when you pass
your Command list to sequential or parallel.
Constructors
forall input output. (TraversableB input, Show (input Symbolic), Show output, Typeable output) => CommandcommandGen :: state Symbolic -> Maybe (gen (input Symbolic))A generator which provides random arguments for a command. If the command cannot be executed in the current state, it should return Nothing.
commandExecute :: input Concrete -> m outputExecutes a command using the arguments generated by commandGen.
commandCallbacks :: [Callback input output state]A set of callbacks which provide optional command configuration such as pre-condtions, post-conditions and state updates.
Optional command configuration.
Constructors
Require (state Symbolic -> input Symbolic -> Bool)A pre-condition for a command that must be verified before the command can be executed. This is mainly used during shrinking to ensure that it is still OK to run a command despite the fact that some previously executed commands may have been removed from the sequence.
Update (forall (v :: Type -> Type). Ord1 v => state v -> input v -> Var output v -> state v)Ensure (state Concrete -> state Concrete -> input Concrete -> output -> Test ())A post-condition for a command that must be verified for the command to be considered a success.
This callback receives the state prior to execution as the first argument, and the state after execution as the second argument.
An instantiation of a Command which can be executed, and its effect evaluated.
A sequence of actions to execute.
Constructors
SequentialsequentialActions :: [Action m state]The sequence of actions.
Instances1Show
Show (Sequential m state)Defined in hedgehog-1.7 · Hedgehog.Internal.State
A sequential prefix of actions to execute, with two branches to execute in parallel.
Constructors
ParallelparallelPrefix :: [Action m state]The sequential prefix.
parallelBranch1 :: [Action m state]The first branch.
parallelBranch2 :: [Action m state]The second branch.
Executes a list of actions sequentially, verifying that all post-conditions are met and no exceptions are thrown.
To generate a sequence of actions to execute, see the sequential combinator in the Hedgehog.Gen module.
Executes the prefix actions sequentially, then executes the two branches in parallel, verifying that no exceptions are thrown and that there is at least one sequential interleaving where all the post-conditions are met.
To generate parallel actions to execute, see the parallel combinator in the Hedgehog.Gen module.
Variables are the potential or actual result of executing an action. They are parameterised by either Symbolic or Concrete depending on the phase of the test.
Symbolic variables are the potential results of actions. These are used when generating the sequence of actions to execute. They allow actions which occur later in the sequence to make use of the result of an action which came earlier in the sequence.
Concrete variables are the actual results of actions. These are used during test execution. They provide access to the actual runtime value of a variable.
The state update Callback for a command needs to be polymorphic in the type of variable because it is used in both the generation and the execution phase.
The order of arguments makes Var FunctorB and TraversableB, which is how Symbolic values are turned into Concrete ones.
Constructors
Var (v a)
Instances5FunctorB, TraversableB, Eq, Ord, Show
FunctorB (Var a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateTraversableB (Var a)Defined in hedgehog-1.7 · Hedgehog.Internal.State(Eq a, Eq1 v) => Eq (Var a v)Defined in hedgehog-1.7 · Hedgehog.Internal.State(Ord a, Ord1 v) => Ord (Var a v)Defined in hedgehog-1.7 · Hedgehog.Internal.State(Show a, Show1 v) => Show (Var a v)Defined in hedgehog-1.7 · Hedgehog.Internal.State
Take the value from a concrete variable.
Take the value from an opaque concrete variable.
Symbolic values: Because hedgehog generates actions in a separate phase before execution, you will sometimes need to refer to the result of a previous action in a generator without knowing the value of the result (e.g., to get the ID of a previously-created user).
Symbolic variables provide a token to stand in for the actual variables at generation time (and in Require/Update callbacks). At execution time, real values are available, so your execute actions work on Concrete variables.
Instances6Eq1, Ord1, Show1, Eq, Ord, Show
Eq1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateOrd1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateShow1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateEq (Symbolic a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateOrd (Symbolic a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateShow (Symbolic a)Defined in hedgehog-1.7 · Hedgehog.Internal.State
Instances9Functor, Foldable, Traversable, Eq1, Ord1, Show1, …
Functor ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateFoldable ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateTraversable ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateEq1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateOrd1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateShow1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateEq a => Eq (Concrete a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateOrd a => Ord (Concrete a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateShow a => Show (Concrete a)Defined in hedgehog-1.7 · Hedgehog.Internal.State
Opaque values.
Useful if you want to put something without a Show instance inside something which you'd like to be able to display.
For example:
data State v =
State {
stateRefs :: [Var (Opaque (IORef Int)) v]
} deriving (Eq, Show)
Transformers
1 declarationDistribute one monad transformer over another.
Functors
9 declarationsFunctorB and TraversableB must be implemented for all Command input types.
This is most easily achieved using DeriveGeneric:
data Register v =
Register Name (Var Pid v)
deriving (Eq, Show, Generic)
instance FunctorB Register
instance TraversableB Register
newtype Unregister (v :: * -> *) =
Unregister Name
deriving (Eq, Show, Generic)
instance FunctorB Unregister
instance TraversableB Unregister
DeriveAnyClass and DerivingStrategies allow a more compact syntax:
data Register v =
Register Name (Var Pid v)
deriving (Eq, Show, Generic, FunctorB, TraversableB)
newtype Unregister (v :: * -> *) =
Unregister Name
deriving (Eq, Show, Generic)
deriving anyclass (FunctorB, TraversableB)
Barbie-types that can be mapped over. Instances of FunctorB should satisfy the following laws:
bmap id = id
bmap f . bmap g = bmap (f . g)
There is a default bmap implementation for Generic types, so instances can derived automatically.
Methods
bmap :: (forall (a :: k). f a -> g a) -> b f -> b g
Instances11FunctorB, …
FunctorB UnitDefined in barbies-2.1.1.0 · Barbies.Internal.TrivialFunctorB VoidDefined in barbies-2.1.1.0 · Barbies.Internal.TrivialFunctorB ProxyDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorBFunctorB (Var a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateFunctorB (Const x)Defined in barbies-2.1.1.0 · Barbies.Internal.FunctorBFunctorB (Constant x)Defined in barbies-2.1.1.0 · Barbies.Internal.FunctorBFunctorB b => FunctorB (Barbie b)Defined in barbies-2.1.1.0 · Barbies.Internal.Wrappers(FunctorB a, FunctorB b) => FunctorB (Product a b)Defined in barbies-2.1.1.0 · Barbies.Internal.FunctorB(FunctorB a, FunctorB b) => FunctorB (Sum a b)Defined in barbies-2.1.1.0 · Barbies.Internal.FunctorBFunctorT b => FunctorB (Flip b f)Defined in barbies-2.1.1.0 · Barbies.Bi(Functor f, FunctorB b) => FunctorB (Compose f b)Defined in barbies-2.1.1.0 · Barbies.Internal.FunctorB
Barbie-types that can be traversed from left to right. Instances should satisfy the following laws:
t . btraverse f = btraverse (t . f) -- naturality
btraverse Data.Functor.Identity = Data.Functor.Identity -- identity
btraverse (Compose . fmap g . f) = Compose . fmap (btraverse g) . btraverse f -- composition
There is a default btraverse implementation for Generic types, so instances can derived automatically.
Methods
btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> b f -> e (b g)
Instances11TraversableB, …
TraversableB UnitDefined in barbies-2.1.1.0 · Barbies.Internal.TrivialTraversableB VoidDefined in barbies-2.1.1.0 · Barbies.Internal.TrivialTraversableB ProxyDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableBTraversableB (Var a)Defined in hedgehog-1.7 · Hedgehog.Internal.StateTraversableB (Const a)Defined in barbies-2.1.1.0 · Barbies.Internal.TraversableBTraversableB (Constant a)Defined in barbies-2.1.1.0 · Barbies.Internal.TraversableBTraversableB b => TraversableB (Barbie b)Defined in barbies-2.1.1.0 · Barbies.Internal.Wrappers(TraversableB a, TraversableB b) => TraversableB (Product a b)Defined in barbies-2.1.1.0 · Barbies.Internal.TraversableB(TraversableB a, TraversableB b) => TraversableB (Sum a b)Defined in barbies-2.1.1.0 · Barbies.Internal.TraversableBTraversableT b => TraversableB (Flip b f)Defined in barbies-2.1.1.0 · Barbies.Bi(Traversable f, TraversableB b) => TraversableB (Compose f b)Defined in barbies-2.1.1.0 · Barbies.Internal.TraversableB
Instances45GTraversable, GApplicative, GFunctor, GDistributive, GBare, GConstraints, …
GTraversable n f g (Rec (P n f a') (f a)) (Rec (P n g a') (g a))Defined in barbies-2.1.1.0 · Barbies.Generics.TraversableGTraversable n f g (Rec a a) (Rec a a)Defined in barbies-2.1.1.0 · Barbies.Generics.TraversableTraversableB b => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableB · orphan0
f g (Rec (b (P0
f)) (b f)) (Rec (b (P0
g)) (b g))TraversableT t => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableT · orphan1
f g (Rec (t (P1
f) x) (t f x)) (Rec (t (P1
g) x) (t g x))Traversable h => GTraversable n f g (Rec (h (P n f a)) (h (f a))) (Rec (h (P n g a)) (h (g a)))Defined in barbies-2.1.1.0 · Barbies.Generics.Traversable(Traversable h, TraversableB b) => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableB · orphan0
f g (Rec (h (b (P0
f))) (h (b f))) (Rec (h (b (P0
g))) (h (b g)))(Traversable h, TraversableT t) => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableT · orphan1
f g (Rec (h (t (P1
f) x)) (h (t f x))) (Rec (h (t (P1
g) x)) (h (t g x)))(Traversable h, Traversable m, TraversableB b) => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableB · orphan0
f g (Rec (m (h (b (P0
f)))) (m (h (b f)))) (Rec (m (h (b (P0
g)))) (m (h (b g))))(Traversable h, Traversable m, TraversableT t) => GTraversableDefined in barbies-2.1.1.0 · Barbies.Internal.TraversableT · orphan1
f g (Rec (m (h (t (P1
f) x))) (m (h (t f x)))) (Rec (m (h (t (P1
g) x))) (m (h (t g x))))GApplicative n f g (Rec (P n f a) (f a)) (Rec (P n g a) (g a)) (Rec (P n (Product f g) a) (Product f g a))Defined in barbies-2.1.1.0 · Barbies.Generics.ApplicativeApplicativeB b => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeB · orphan0
f g (Rec (b (P0
f)) (b f)) (Rec (b (P0
g)) (b g)) (Rec (b (P0
(Product f g))) (b (Product f g)))ApplicativeT t => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeT · orphan1
f g (Rec (t (P1
f) x) (t f x)) (Rec (t (P1
g) x) (t g x)) (Rec (t (P1
(Product f g)) x) (t (Product f g) x))Applicative h => GApplicative n f g (Rec (h (P n f a)) (h (f a))) (Rec (h (P n g a)) (h (g a))) (Rec (h (P n (Product f g) a)) (h (Product f g a)))Defined in barbies-2.1.1.0 · Barbies.Generics.ApplicativeMonoid x => GApplicative n f g (Rec x x) (Rec x x) (Rec x x)Defined in barbies-2.1.1.0 · Barbies.Generics.Applicative(Applicative h, ApplicativeB b) => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeB · orphan0
f g (Rec (h (b (P0
f))) (h (b f))) (Rec (h (b (P0
g))) (h (b g))) (Rec (h (b (P0
(Product f g)))) (h (b (Product f g))))(Applicative h, ApplicativeT t) => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeT · orphan1
f g (Rec (h (t (P1
f) x)) (h (t f x))) (Rec (h (t (P1
g) x)) (h (t g x))) (Rec (h (t (P1
(Product f g)) x)) (h (t (Product f g) x)))(Applicative h, Applicative m, ApplicativeB b) => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeB · orphan0
f g (Rec (m (h (b (P0
f)))) (m (h (b f)))) (Rec (m (h (b (P0
g)))) (m (h (b g)))) (Rec (m (h (b (P0
(Product f g))))) (m (h (b (Product f g)))))(Applicative h, Applicative m, ApplicativeT t) => GApplicativeDefined in barbies-2.1.1.0 · Barbies.Internal.ApplicativeT · orphan1
f g (Rec (m (h (t (P1
f) x))) (m (h (t f x)))) (Rec (m (h (t (P1
g) x))) (m (h (t g x)))) (Rec (m (h (t (P1
(Product f g)) x))) (m (h (t (Product f g) x))))GConstraints n c f (Rec a' a) (Rec b' b) (Rec b' b)Defined in barbies-2.1.1.0 · Barbies.Generics.ConstraintsGFunctor n f g (Rec (P n f a') (f a)) (Rec (P n g a') (g a))Defined in barbies-2.1.1.0 · Barbies.Generics.FunctorGFunctor n f g (Rec x x) (Rec x x)Defined in barbies-2.1.1.0 · Barbies.Generics.FunctorFunctorB b => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorB · orphan0
f g (Rec (b' (P0
f)) (b f)) (Rec (b' (P0
g)) (b g))FunctorT t => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorT · orphan1
f g (Rec (t (P1
f) x) (t f x)) (Rec (t (P1
g) x) (t g x))Functor h => GFunctor n f g (Rec (h (P n f a')) (h (f a))) (Rec (h (P n g a')) (h (g a)))Defined in barbies-2.1.1.0 · Barbies.Generics.Functor(Functor h, FunctorB b) => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorB · orphan0
f g (Rec (h' (b' (P0
f))) (h (b f))) (Rec (h' (b' (P0
g))) (h (b g)))(Functor h, FunctorT t) => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorT · orphan1
f g (Rec (h (t (P1
f) x)) (h (t f x))) (Rec (h (t (P1
g) x)) (h (t g x)))(Functor h, Functor m, FunctorB b) => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorB · orphan0
f g (Rec (m' (h' (b' (P0
f)))) (m (h (b f)))) (Rec (m' (h' (b' (P0
g)))) (m (h (b g))))(Functor h, Functor m, FunctorT t) => GFunctorDefined in barbies-2.1.1.0 · Barbies.Internal.FunctorT · orphan1
f g (Rec (m (h (t (P1
f) x))) (m (h (t f x)))) (Rec (m (h (t (P1
g) x))) (m (h (t g x))))Functor f => GDistributive n f (Rec (P n g a) (g a)) (Rec (P n (Compose f g) a) (Compose f g a))Defined in barbies-2.1.1.0 · Barbies.Generics.Distributive(Functor f, DistributiveB b) => GDistributiveDefined in barbies-2.1.1.0 · Barbies.Internal.DistributiveB · orphan0
f (Rec (b' (P0
g)) (b g)) (Rec (b' (P0
(Compose f g))) (b (Compose f g)))(Functor f, DistributiveT t) => GDistributiveDefined in barbies-2.1.1.0 · Barbies.Internal.DistributiveT · orphan1
f (Rec (t (P1
g) x) (t g x)) (Rec (t (P1
(Compose f g)) x) (t (Compose f g) x))(Functor f, Distributive h) => GDistributive n f (Rec (h (P n g a)) (h (g a))) (Rec (h (P n (Compose f g) a)) (h (Compose f g a)))Defined in barbies-2.1.1.0 · Barbies.Generics.Distributive(Functor f, Distributive h, DistributiveB b) => GDistributive n f (Rec (h (b (P n g))) (h (b g))) (Rec (h (b (P n (Compose f g)))) (h (b (Compose f g))))Defined in barbies-2.1.1.0 · Barbies.Internal.DistributiveB · orphan(Functor f, Distributive h, DistributiveT t) => GDistributiveDefined in barbies-2.1.1.0 · Barbies.Internal.DistributiveT · orphan1
f (Rec (h (t (P1
g) x)) (h (t g x))) (Rec (h (t (P1
(Compose f g)) x)) (h (t (Compose f g) x)))BareB b => GBareDefined in barbies-2.1.1.0 · Barbies.Internal.BareB · orphan0
(Rec (b Covered (P0
Identity)) (b Covered Identity)) (Rec (b Bare (P0
Identity)) (b Bare Identity))Coercible a b => GBare n (Rec (P n Identity a) (Identity a)) (Rec b b)Defined in barbies-2.1.1.0 · Barbies.Generics.Bare(Functor h, BareB b) => GBareDefined in barbies-2.1.1.0 · Barbies.Internal.BareB · orphan0
(Rec (h (b Covered (P0
Identity))) (h (b Covered Identity))) (Rec (h (b Bare (P0
Identity))) (h (b Bare Identity)))(Functor h, Functor m, BareB b) => GBareDefined in barbies-2.1.1.0 · Barbies.Internal.BareB · orphan0
(Rec (m (h (b Covered (P0
Identity)))) (m (h (b Covered Identity)))) (Rec (m (h (b Bare (P0
Identity)))) (m (h (b Bare Identity))))repbi ~ repbb => GBare n (Rec repbi repbi) (Rec repbb repbb)Defined in barbies-2.1.1.0 · Barbies.Generics.Bare(ConstraintsB b, AllB c b) => GConstraintsDefined in barbies-2.1.1.0 · Barbies.Internal.ConstraintsB · orphan0
c f (Other (b' (P0
X)) (b X)) (Rec (b' (P0
f)) (b f)) (Rec (b' (P0
(Product (Dict c) f))) (b (Product (Dict c) f)))(ConstraintsB b, AllB c b) => GConstraintsDefined in barbies-2.1.1.0 · Barbies.Internal.ConstraintsB · orphan0
c f (Self (b' (P0
X)) (b X)) (Rec (b' (P0
f)) (b f)) (Rec (b' (P0
(Product (Dict c) f))) (b (Product (Dict c) f)))(ConstraintsT t, AllT c t) => GConstraintsDefined in barbies-2.1.1.0 · Barbies.Internal.ConstraintsT · orphan1
c f (Other (t' (P1
X) Y) (t X Y)) (Rec (t' (P1
f) (P0
y)) (t f y)) (Rec (t' (P1
(Product (Dict c) f)) (P0
y)) (t (Product (Dict c) f) y))(ConstraintsT t, AllT c t) => GConstraintsDefined in barbies-2.1.1.0 · Barbies.Internal.ConstraintsT · orphan1
c f (Self (t' (P1
X) Y) (t X Y)) (Rec (t' (P1
f) (P0
y)) (t f y)) (Rec (t' (P1
(Product (Dict c) f)) (P0
y)) (t (Product (Dict c) f) y))GConstraints n c f (Rec (P n X a') (X a)) (Rec (P n f a') (f a)) (Rec (P n (Product (Dict c) f) a') (Product (Dict c) f a))Defined in barbies-2.1.1.0 · Barbies.Generics.Constraintstype GAll n c (Rec l r) = GAllRec n c l rDefined in barbies-2.1.1.0 · Barbies.Generics.Constraints
Lifting of the Eq class to unary type constructors.
Any instance should be subject to the following law that canonicity is preserved:
liftEq (==) = (==)
This class therefore represents the generalization of Eq by decomposing its main method into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.
Instances67Lifting2, Lifting, Eq1, …
Eq1 ComplexDefined in base-4.20.2.0 · Data.Functor.ClassesExample1 expression eq1 (1 :+ 2) (1 :+ 2)True
Example1 expression eq1 (1 :+ 2) (1 :+ 3)False
Eq1 SCCDefined in containers-0.7 · Data.GraphEq1 IntMapDefined in containers-0.7 · Data.IntMap.InternalEq1 SeqDefined in containers-0.7 · Data.Sequence.InternalEq1 SetDefined in containers-0.7 · Data.Set.InternalEq1 TreeDefined in containers-0.7 · Data.TreeEq1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 IdentityDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 DownDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 MaybeDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 SoloDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.ClassEq1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateEq1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateEq1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayEq1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayEq1 []Defined in base-4.20.2.0 · Data.Functor.ClassesEq1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesEq1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 f => Eq1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftEq1 m => Eq1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeEq a => Eq1 (Either a)Defined in base-4.20.2.0 · Data.Functor.ClassesEq a => Eq1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.ClassesEq k => Eq1 (Map k)Defined in containers-0.7 · Data.Map.Internal(GEq1 NonV4 (Rep1 f), Generic1 f) => Eq1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.InternalEq1 (Tagged s)Defined in tagged-0.8.9 · Data.TaggedEq1 f => Eq1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphanEq1 f => Eq1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsEq1 f => Eq1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityEq1 f => Eq1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseEq a => Eq1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesEq a => Eq1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant(Generic1 f, Eq1 (Rep1 f)) => Eq1 (Generically1 f)Defined in base-4.20.2.0 · Data.Functor.Classes(Eq a, Eq b) => Eq1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes(Eq e, Eq1 m) => Eq1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Eq w, Eq1 m) => Eq1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Eq w, Eq1 m) => Eq1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.StrictLifting Eq1 LiftDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Eq1 MaybeTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Eq1 BackwardsDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Eq1 IdentityTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Eq1 ReverseDefined in constraints-0.14.2 · Data.Constraint.LiftingEq e => Lifting Eq1 (ExceptT e)Defined in constraints-0.14.2 · Data.Constraint.LiftingEq w => Lifting Eq1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingEq w => Lifting Eq1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Eq1 ProductDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Eq1 SumDefined in constraints-0.14.2 · Data.Constraint.LiftingEq1 f => Lifting Eq1 (Product f)Defined in constraints-0.14.2 · Data.Constraint.LiftingEq1 f => Lifting Eq1 (Sum f)Defined in constraints-0.14.2 · Data.Constraint.LiftingEq1 f => Lifting Eq1 (Compose f)Defined in constraints-0.14.2 · Data.Constraint.LiftingEq c => Eq1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Eq1 f, Eq1 g) => Eq1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Eq1 f, Eq1 g) => Eq1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum(Eq1 f, Eq1 g) => Eq1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Eq1 f, Eq1 g) => Eq1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Eq a, Eq b, Eq c) => Eq1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.ClassesEq1 f => Eq1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Eq1 f, Eq1 g) => Eq1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Eq1 f, Eq1 g) => Eq1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
Lift the standard (==) function through the type constructor.
Lifting of the Ord class to unary type constructors.
Any instance should be subject to the following law that canonicity is preserved:
liftCompare compare = compare
This class therefore represents the generalization of Ord by decomposing its main method into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.
Instances65Lifting2, Lifting, Ord1, …
Ord1 IntMapDefined in containers-0.7 · Data.IntMap.InternalOrd1 SeqDefined in containers-0.7 · Data.Sequence.InternalOrd1 SetDefined in containers-0.7 · Data.Set.InternalOrd1 TreeDefined in containers-0.7 · Data.TreeOrd1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 IdentityDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 DownDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 MaybeDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 SoloDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.ClassOrd1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateOrd1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateOrd1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayOrd1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayOrd1 []Defined in base-4.20.2.0 · Data.Functor.ClassesOrd1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 f => Ord1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftOrd1 m => Ord1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeOrd a => Ord1 (Either a)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd a => Ord1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd k => Ord1 (Map k)Defined in containers-0.7 · Data.Map.Internal(GOrd1 NonV4 (Rep1 f), Generic1 f) => Ord1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.InternalOrd1 (Tagged s)Defined in tagged-0.8.9 · Data.TaggedOrd1 f => Ord1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphanOrd1 f => Ord1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsOrd1 f => Ord1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityOrd1 f => Ord1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseOrd a => Ord1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd a => Ord1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant(Generic1 f, Ord1 (Rep1 f)) => Ord1 (Generically1 f)Defined in base-4.20.2.0 · Data.Functor.Classes(Ord a, Ord b) => Ord1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes(Ord e, Ord1 m) => Ord1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Ord w, Ord1 m) => Ord1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Ord w, Ord1 m) => Ord1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.StrictLifting Ord1 LiftDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Ord1 MaybeTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Ord1 BackwardsDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Ord1 IdentityTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Ord1 ReverseDefined in constraints-0.14.2 · Data.Constraint.LiftingOrd e => Lifting Ord1 (ExceptT e)Defined in constraints-0.14.2 · Data.Constraint.LiftingOrd w => Lifting Ord1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingOrd w => Lifting Ord1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Ord1 ProductDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Ord1 SumDefined in constraints-0.14.2 · Data.Constraint.LiftingOrd1 f => Lifting Ord1 (Product f)Defined in constraints-0.14.2 · Data.Constraint.LiftingOrd1 f => Lifting Ord1 (Sum f)Defined in constraints-0.14.2 · Data.Constraint.LiftingOrd1 f => Lifting Ord1 (Compose f)Defined in constraints-0.14.2 · Data.Constraint.LiftingOrd c => Ord1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Ord1 f, Ord1 g) => Ord1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Ord1 f, Ord1 g) => Ord1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum(Ord1 f, Ord1 g) => Ord1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Ord1 f, Ord1 g) => Ord1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Ord a, Ord b, Ord c) => Ord1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd1 f => Ord1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Ord1 f, Ord1 g) => Ord1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Ord1 f, Ord1 g) => Ord1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
Lift the standard compare function through the type constructor.
Lifting of the Show class to unary type constructors.
Any instance should be subject to the following laws that canonicity is preserved:
liftShowsPrec showsPrec showList = showsPrec
liftShowList showsPrec showList = showList
This class therefore represents the generalization of Show by decomposing it's methods into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.
Instances69Lifting2, Lifting, Show1, …
Show1 ComplexDefined in base-4.20.2.0 · Data.Functor.ClassesExample1 expression showsPrec1 0 (2 :+ 3) """2 :+ 3"
Show1 SCCDefined in containers-0.7 · Data.GraphShow1 IntMapDefined in containers-0.7 · Data.IntMap.InternalShow1 SeqDefined in containers-0.7 · Data.Sequence.InternalShow1 SetDefined in containers-0.7 · Data.Set.InternalShow1 TreeDefined in containers-0.7 · Data.TreeShow1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 IdentityDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 DownDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 MaybeDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 SoloDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.ClassShow1 ConcreteDefined in hedgehog-1.7 · Hedgehog.Internal.StateShow1 SymbolicDefined in hedgehog-1.7 · Hedgehog.Internal.StateShow1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayShow1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayShow1 []Defined in base-4.20.2.0 · Data.Functor.ClassesShow1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 f => Show1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftShow1 m => Show1 (NodeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.TreeShow1 m => Show1 (TreeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.TreeShow1 m => Show1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeShow a => Show1 (Either a)Defined in base-4.20.2.0 · Data.Functor.ClassesShow a => Show1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.ClassesShow k => Show1 (Map k)Defined in containers-0.7 · Data.Map.Internal(GShow1 NonV4 (Rep1 f), Generic1 f) => Show1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.InternalShow1 (Dict c)Defined in barbies-2.1.1.0 · Barbies.Internal.DictsShow1 (Tagged s)Defined in tagged-0.8.9 · Data.TaggedShow1 f => Show1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphanShow1 f => Show1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsShow1 f => Show1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityShow1 f => Show1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseShow a => Show1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesShow a => Show1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant(Show a, Show b) => Show1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes(Show e, Show1 m) => Show1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Show w, Show1 m) => Show1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Show w, Show1 m) => Show1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.StrictLifting Show1 LiftDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Show1 MaybeTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Show1 BackwardsDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Show1 IdentityTDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting Show1 ReverseDefined in constraints-0.14.2 · Data.Constraint.LiftingShow e => Lifting Show1 (ExceptT e)Defined in constraints-0.14.2 · Data.Constraint.LiftingShow w => Lifting Show1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingShow w => Lifting Show1 (WriterT w)Defined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Show1 ProductDefined in constraints-0.14.2 · Data.Constraint.LiftingLifting2 Show1 SumDefined in constraints-0.14.2 · Data.Constraint.LiftingShow1 f => Lifting Show1 (Product f)Defined in constraints-0.14.2 · Data.Constraint.LiftingShow1 f => Lifting Show1 (Sum f)Defined in constraints-0.14.2 · Data.Constraint.LiftingShow1 f => Lifting Show1 (Compose f)Defined in constraints-0.14.2 · Data.Constraint.LiftingShow c => Show1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Show1 f, Show1 g) => Show1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Show1 f, Show1 g) => Show1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum(Show1 f, Show1 g) => Show1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Show1 f, Show1 g) => Show1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Show a, Show b, Show c) => Show1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.ClassesShow1 f => Show1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan(Show1 f, Show1 g) => Show1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Show1 f, Show1 g) => Show1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
Deprecated
1 declarationDeprecated. Replace with Hedgehog.TraversableB (defined in Data.Functor.Barbie) which can be derived automatically using GHC.Generics
Higher-order traversable functors.
Deprecated in favor of TraversableB which can be derived using GHC.Generics
Methods
htraverse :: Applicative f => (forall a. g a -> f (h a)) -> t g -> f (t h)