hedgehog-0.5.3: Hedgehog will eat all your bugs.

Safe HaskellNone
LanguageHaskell98

Hedgehog

Contents

Description

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 Range

Once 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) === xs

And 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.

Synopsis

Properties

data Property Source #

A property test, along with some configurable limits like how many times to run the test.

data PropertyT m a Source #

The property monad transformer allows both the generation of test inputs and the assertion of expectations.

Instances

MonadTrans PropertyT Source # 

Methods

lift :: Monad m => m a -> PropertyT m a #

Distributive PropertyT Source # 

Associated Types

type Transformer (f :: (* -> *) -> * -> *) (PropertyT :: (* -> *) -> * -> *) (m :: * -> *) :: Constraint Source #

Methods

distribute :: Transformer f PropertyT m => PropertyT (f m) a -> f (PropertyT m) a Source #

MonadBase b m => MonadBase b (PropertyT m) Source # 

Methods

liftBase :: b α -> PropertyT m α #

MonadState s m => MonadState s (PropertyT m) Source # 

Methods

get :: PropertyT m s #

put :: s -> PropertyT m () #

state :: (s -> (a, s)) -> PropertyT m a #

MonadReader r m => MonadReader r (PropertyT m) Source # 

Methods

ask :: PropertyT m r #

local :: (r -> r) -> PropertyT m a -> PropertyT m a #

reader :: (r -> a) -> PropertyT m a #

MonadError e m => MonadError e (PropertyT m) Source # 

Methods

throwError :: e -> PropertyT m a #

catchError :: PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

Monad m => Monad (PropertyT m) Source # 

Methods

(>>=) :: PropertyT m a -> (a -> PropertyT m b) -> PropertyT m b #

(>>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

return :: a -> PropertyT m a #

fail :: String -> PropertyT m a #

Functor m => Functor (PropertyT m) Source # 

Methods

fmap :: (a -> b) -> PropertyT m a -> PropertyT m b #

(<$) :: a -> PropertyT m b -> PropertyT m a #

Monad m => Applicative (PropertyT m) Source # 

Methods

pure :: a -> PropertyT m a #

(<*>) :: PropertyT m (a -> b) -> PropertyT m a -> PropertyT m b #

liftA2 :: (a -> b -> c) -> PropertyT m a -> PropertyT m b -> PropertyT m c #

(*>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

(<*) :: PropertyT m a -> PropertyT m b -> PropertyT m a #

MonadIO m => MonadIO (PropertyT m) Source # 

Methods

liftIO :: IO a -> PropertyT m a #

MonadPlus m => Alternative (PropertyT m) Source # 

Methods

empty :: PropertyT m a #

(<|>) :: PropertyT m a -> PropertyT m a -> PropertyT m a #

some :: PropertyT m a -> PropertyT m [a] #

many :: PropertyT m a -> PropertyT m [a] #

MonadPlus m => MonadPlus (PropertyT m) Source # 

Methods

mzero :: PropertyT m a #

mplus :: PropertyT m a -> PropertyT m a -> PropertyT m a #

MonadCatch m => MonadCatch (PropertyT m) Source # 

Methods

catch :: Exception e => PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

MonadThrow m => MonadThrow (PropertyT m) Source # 

Methods

throwM :: Exception e => e -> PropertyT m a #

PrimMonad m => PrimMonad (PropertyT m) Source # 

Associated Types

type PrimState (PropertyT m :: * -> *) :: * #

Monad m => MonadTest (PropertyT m) Source # 

Methods

liftTest :: Test a -> PropertyT m a Source #

MFunctor * PropertyT Source # 

Methods

hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b #

type Transformer t PropertyT m Source # 
type PrimState (PropertyT m) Source # 

data Group Source #

A named collection of property tests.

Constructors

Group 

property :: HasCallStack => PropertyT IO () -> Property Source #

Creates a property with the default configuration.

test :: Monad m => TestT m a -> PropertyT m a Source #

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.

One use case for this is writing tests which use ResourceT:

  property $ do
    n <- forAll $ Gen.int64 Range.linearBounded
    test . runResourceT $ do
      -- test with resource usage here

forAll :: (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

forAllWith :: (Monad m, HasCallStack) => (a -> String) -> Gen a -> PropertyT m a Source #

Generates a random input for the test by running the provided generator.

This is a the same as forAll but allows the user to provide a custom rendering function. This is useful for values which don't have a Show instance.

discard :: Monad m => PropertyT m a Source #

Discards the current test entirely.

check :: MonadIO m => Property -> m Bool Source #

Check a property.

recheck :: MonadIO m => Size -> Seed -> Property -> m () Source #

Check a property using a specific size and seed.

discover :: TExpQ Group Source #

Discover all the properties in a module.

Functions starting with prop_ are assumed to be properties.

checkParallel :: MonadIO m => Group -> m Bool Source #

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)
    ]

checkSequential :: MonadIO m => Group -> m Bool Source #

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)
    ]

withTests :: TestLimit -> Property -> Property Source #

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.

data TestLimit Source #

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

Instances

Enum TestLimit Source # 
Eq TestLimit Source # 
Integral TestLimit Source # 
Num TestLimit Source # 
Ord TestLimit Source # 
Real TestLimit Source # 
Show TestLimit Source # 
Lift TestLimit Source # 

Methods

lift :: TestLimit -> Q Exp #

withDiscards :: DiscardLimit -> Property -> Property Source #

Set the number of times a property is allowed to discard before the test runner gives up.

data DiscardLimit Source #

The number of discards to allow before giving up.

Can be constructed using numeric literals:

  10000 :: DiscardLimit

Instances

Enum DiscardLimit Source # 
Eq DiscardLimit Source # 
Integral DiscardLimit Source # 
Num DiscardLimit Source # 
Ord DiscardLimit Source # 
Real DiscardLimit Source # 
Show DiscardLimit Source # 
Lift DiscardLimit Source # 

Methods

lift :: DiscardLimit -> Q Exp #

withShrinks :: ShrinkLimit -> Property -> Property Source #

Set the number of times a property is allowed to shrink before the test runner gives up and prints the counterexample.

data ShrinkLimit Source #

The number of shrinks to try before giving up on shrinking.

Can be constructed using numeric literals:

  1000 :: ShrinkLimit

Instances

Enum ShrinkLimit Source # 
Eq ShrinkLimit Source # 
Integral ShrinkLimit Source # 
Num ShrinkLimit Source # 
Ord ShrinkLimit Source # 
Real ShrinkLimit Source # 
Show ShrinkLimit Source # 
Lift ShrinkLimit Source # 

Methods

lift :: ShrinkLimit -> Q Exp #

withRetries :: ShrinkRetries -> Property -> Property Source #

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.

data ShrinkRetries Source #

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

Instances

Enum ShrinkRetries Source # 
Eq ShrinkRetries Source # 
Integral ShrinkRetries Source # 
Num ShrinkRetries Source # 
Ord ShrinkRetries Source # 
Real ShrinkRetries Source # 
Show ShrinkRetries Source # 
Lift ShrinkRetries Source # 

Methods

lift :: ShrinkRetries -> Q Exp #

Generating Test Data

type Gen = GenT Identity Source #

Generator for random values of a.

data GenT m a Source #

Monad transformer which can generate random values of a.

Instances

MMonad GenT Source # 

Methods

embed :: Monad n => (forall a. m a -> GenT n a) -> GenT m b -> GenT n b #

MonadTrans GenT Source # 

Methods

lift :: Monad m => m a -> GenT m a #

Distributive GenT Source # 

Associated Types

type Transformer (f :: (* -> *) -> * -> *) (GenT :: (* -> *) -> * -> *) (m :: * -> *) :: Constraint Source #

Methods

distribute :: Transformer f GenT m => GenT (f m) a -> f (GenT m) a Source #

MonadBase b m => MonadBase b (GenT m) Source # 

Methods

liftBase :: b α -> GenT m α #

MonadWriter w m => MonadWriter w (GenT m) Source # 

Methods

writer :: (a, w) -> GenT m a #

tell :: w -> GenT m () #

listen :: GenT m a -> GenT m (a, w) #

pass :: GenT m (a, w -> w) -> GenT m a #

MonadState s m => MonadState s (GenT m) Source # 

Methods

get :: GenT m s #

put :: s -> GenT m () #

state :: (s -> (a, s)) -> GenT m a #

MonadReader r m => MonadReader r (GenT m) Source # 

Methods

ask :: GenT m r #

local :: (r -> r) -> GenT m a -> GenT m a #

reader :: (r -> a) -> GenT m a #

MonadError e m => MonadError e (GenT m) Source # 

Methods

throwError :: e -> GenT m a #

catchError :: GenT m a -> (e -> GenT m a) -> GenT m a #

Monad m => Monad (GenT m) Source # 

Methods

(>>=) :: GenT m a -> (a -> GenT m b) -> GenT m b #

(>>) :: GenT m a -> GenT m b -> GenT m b #

return :: a -> GenT m a #

fail :: String -> GenT m a #

Functor m => Functor (GenT m) Source # 

Methods

fmap :: (a -> b) -> GenT m a -> GenT m b #

(<$) :: a -> GenT m b -> GenT m a #

Monad m => Applicative (GenT m) Source # 

Methods

pure :: a -> GenT m a #

(<*>) :: GenT m (a -> b) -> GenT m a -> GenT m b #

liftA2 :: (a -> b -> c) -> GenT m a -> GenT m b -> GenT m c #

(*>) :: GenT m a -> GenT m b -> GenT m b #

(<*) :: GenT m a -> GenT m b -> GenT m a #

MonadIO m => MonadIO (GenT m) Source # 

Methods

liftIO :: IO a -> GenT m a #

Monad m => Alternative (GenT m) Source # 

Methods

empty :: GenT m a #

(<|>) :: GenT m a -> GenT m a -> GenT m a #

some :: GenT m a -> GenT m [a] #

many :: GenT m a -> GenT m [a] #

Monad m => MonadPlus (GenT m) Source # 

Methods

mzero :: GenT m a #

mplus :: GenT m a -> GenT m a -> GenT m a #

MonadCatch m => MonadCatch (GenT m) Source # 

Methods

catch :: Exception e => GenT m a -> (e -> GenT m a) -> GenT m a #

MonadThrow m => MonadThrow (GenT m) Source # 

Methods

throwM :: Exception e => e -> GenT m a #

PrimMonad m => PrimMonad (GenT m) Source # 

Associated Types

type PrimState (GenT m :: * -> *) :: * #

Methods

primitive :: (State# (PrimState (GenT m)) -> (#TupleRep [RuntimeRep], LiftedRep, State# (PrimState (GenT m)), a#)) -> GenT m a #

MonadResource m => MonadResource (GenT m) Source # 

Methods

liftResourceT :: ResourceT IO a -> GenT m a #

Monad m => MonadGen (GenT m) Source # 

Methods

liftGen :: Gen a -> GenT m a Source #

shrinkGen :: (a -> [a]) -> GenT m a -> GenT m a Source #

pruneGen :: GenT m a -> GenT m a Source #

scaleGen :: (Size -> Size) -> GenT m a -> GenT m a Source #

freezeGen :: GenT m a -> GenT m (a, GenT m a) Source #

MFunctor * GenT Source # 

Methods

hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b #

(Monad m, Semigroup a) => Semigroup (GenT m a) Source # 

Methods

(<>) :: GenT m a -> GenT m a -> GenT m a #

sconcat :: NonEmpty (GenT m a) -> GenT m a #

stimes :: Integral b => b -> GenT m a -> GenT m a #

(Monad m, Monoid a) => Monoid (GenT m a) Source # 

Methods

mempty :: GenT m a #

mappend :: GenT m a -> GenT m a -> GenT m a #

mconcat :: [GenT m a] -> GenT m a #

type Transformer t GenT m Source # 
type PrimState (GenT m) Source # 
type PrimState (GenT m) = PrimState m

class Monad m => MonadGen m where Source #

Class of monads which can generate input data for tests.

The functions on this class can, and should, be used without their Gen suffix by importing Hedgehog.Gen qualified.

Minimal complete definition

liftGen, shrinkGen, pruneGen, scaleGen, freezeGen

Methods

liftGen :: Gen a -> m a Source #

See Gen.lift

shrinkGen :: (a -> [a]) -> m a -> m a Source #

See Gen.shrink

pruneGen :: m a -> m a Source #

See Gen.prune

scaleGen :: (Size -> Size) -> m a -> m a Source #

See Gen.scale

freezeGen :: m a -> m (a, m a) Source #

See Gen.freeze

Instances

MonadGen m => MonadGen (MaybeT m) Source # 

Methods

liftGen :: Gen a -> MaybeT m a Source #

shrinkGen :: (a -> [a]) -> MaybeT m a -> MaybeT m a Source #

pruneGen :: MaybeT m a -> MaybeT m a Source #

scaleGen :: (Size -> Size) -> MaybeT m a -> MaybeT m a Source #

freezeGen :: MaybeT m a -> MaybeT m (a, MaybeT m a) Source #

Monad m => MonadGen (GenT m) Source # 

Methods

liftGen :: Gen a -> GenT m a Source #

shrinkGen :: (a -> [a]) -> GenT m a -> GenT m a Source #

pruneGen :: GenT m a -> GenT m a Source #

scaleGen :: (Size -> Size) -> GenT m a -> GenT m a Source #

freezeGen :: GenT m a -> GenT m (a, GenT m a) Source #

(MonadGen m, Monoid w) => MonadGen (WriterT w m) Source # 

Methods

liftGen :: Gen a -> WriterT w m a Source #

shrinkGen :: (a -> [a]) -> WriterT w m a -> WriterT w m a Source #

pruneGen :: WriterT w m a -> WriterT w m a Source #

scaleGen :: (Size -> Size) -> WriterT w m a -> WriterT w m a Source #

freezeGen :: WriterT w m a -> WriterT w m (a, WriterT w m a) Source #

MonadGen m => MonadGen (StateT s m) Source # 

Methods

liftGen :: Gen a -> StateT s m a Source #

shrinkGen :: (a -> [a]) -> StateT s m a -> StateT s m a Source #

pruneGen :: StateT s m a -> StateT s m a Source #

scaleGen :: (Size -> Size) -> StateT s m a -> StateT s m a Source #

freezeGen :: StateT s m a -> StateT s m (a, StateT s m a) Source #

MonadGen m => MonadGen (ExceptT x m) Source # 

Methods

liftGen :: Gen a -> ExceptT x m a Source #

shrinkGen :: (a -> [a]) -> ExceptT x m a -> ExceptT x m a Source #

pruneGen :: ExceptT x m a -> ExceptT x m a Source #

scaleGen :: (Size -> Size) -> ExceptT x m a -> ExceptT x m a Source #

freezeGen :: ExceptT x m a -> ExceptT x m (a, ExceptT x m a) Source #

MonadGen m => MonadGen (IdentityT * m) Source # 

Methods

liftGen :: Gen a -> IdentityT * m a Source #

shrinkGen :: (a -> [a]) -> IdentityT * m a -> IdentityT * m a Source #

pruneGen :: IdentityT * m a -> IdentityT * m a Source #

scaleGen :: (Size -> Size) -> IdentityT * m a -> IdentityT * m a Source #

freezeGen :: IdentityT * m a -> IdentityT * m (a, IdentityT * m a) Source #

MonadGen m => MonadGen (StateT s m) Source # 

Methods

liftGen :: Gen a -> StateT s m a Source #

shrinkGen :: (a -> [a]) -> StateT s m a -> StateT s m a Source #

pruneGen :: StateT s m a -> StateT s m a Source #

scaleGen :: (Size -> Size) -> StateT s m a -> StateT s m a Source #

freezeGen :: StateT s m a -> StateT s m (a, StateT s m a) Source #

(MonadGen m, Monoid w) => MonadGen (WriterT w m) Source # 

Methods

liftGen :: Gen a -> WriterT w m a Source #

shrinkGen :: (a -> [a]) -> WriterT w m a -> WriterT w m a Source #

pruneGen :: WriterT w m a -> WriterT w m a Source #

scaleGen :: (Size -> Size) -> WriterT w m a -> WriterT w m a Source #

freezeGen :: WriterT w m a -> WriterT w m (a, WriterT w m a) Source #

MonadGen m => MonadGen (ReaderT * r m) Source # 

Methods

liftGen :: Gen a -> ReaderT * r m a Source #

shrinkGen :: (a -> [a]) -> ReaderT * r m a -> ReaderT * r m a Source #

pruneGen :: ReaderT * r m a -> ReaderT * r m a Source #

scaleGen :: (Size -> Size) -> ReaderT * r m a -> ReaderT * r m a Source #

freezeGen :: ReaderT * r m a -> ReaderT * r m (a, ReaderT * r m a) Source #

(MonadGen m, Monoid w) => MonadGen (RWST r w s m) Source # 

Methods

liftGen :: Gen a -> RWST r w s m a Source #

shrinkGen :: (a -> [a]) -> RWST r w s m a -> RWST r w s m a Source #

pruneGen :: RWST r w s m a -> RWST r w s m a Source #

scaleGen :: (Size -> Size) -> RWST r w s m a -> RWST r w s m a Source #

freezeGen :: RWST r w s m a -> RWST r w s m (a, RWST r w s m a) Source #

(MonadGen m, Monoid w) => MonadGen (RWST r w s m) Source # 

Methods

liftGen :: Gen a -> RWST r w s m a Source #

shrinkGen :: (a -> [a]) -> RWST r w s m a -> RWST r w s m a Source #

pruneGen :: RWST r w s m a -> RWST r w s m a Source #

scaleGen :: (Size -> Size) -> RWST r w s m a -> RWST r w s m a Source #

freezeGen :: RWST r w s m a -> RWST r w s m (a, RWST r w s m a) Source #

data Range a Source #

A range describes the bounds of a number to generate, which may or may not be dependent on a Size.

The constructor takes an origin between the lower and upper bound, and a function from Size to bounds. As the size goes towards 0, the values go towards the origin.

Instances

Functor Range Source # 

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

newtype Size Source #

Tests are parameterized by the size of the randomly-generated data, the meaning of which depends on the particular generator used.

Constructors

Size 

Fields

Instances

Enum Size Source # 

Methods

succ :: Size -> Size #

pred :: Size -> Size #

toEnum :: Int -> Size #

fromEnum :: Size -> Int #

enumFrom :: Size -> [Size] #

enumFromThen :: Size -> Size -> [Size] #

enumFromTo :: Size -> Size -> [Size] #

enumFromThenTo :: Size -> Size -> Size -> [Size] #

Eq Size Source # 

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Integral Size Source # 

Methods

quot :: Size -> Size -> Size #

rem :: Size -> Size -> Size #

div :: Size -> Size -> Size #

mod :: Size -> Size -> Size #

quotRem :: Size -> Size -> (Size, Size) #

divMod :: Size -> Size -> (Size, Size) #

toInteger :: Size -> Integer #

Num Size Source # 

Methods

(+) :: Size -> Size -> Size #

(-) :: Size -> Size -> Size #

(*) :: Size -> Size -> Size #

negate :: Size -> Size #

abs :: Size -> Size #

signum :: Size -> Size #

fromInteger :: Integer -> Size #

Ord Size Source # 

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Read Size Source # 
Real Size Source # 

Methods

toRational :: Size -> Rational #

Show Size Source # 

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

data Seed Source #

A splittable random number generator.

Constructors

Seed 

Fields

Instances

Eq Seed Source # 

Methods

(==) :: Seed -> Seed -> Bool #

(/=) :: Seed -> Seed -> Bool #

Ord Seed Source # 

Methods

compare :: Seed -> Seed -> Ordering #

(<) :: Seed -> Seed -> Bool #

(<=) :: Seed -> Seed -> Bool #

(>) :: Seed -> Seed -> Bool #

(>=) :: Seed -> Seed -> Bool #

max :: Seed -> Seed -> Seed #

min :: Seed -> Seed -> Seed #

Read Seed Source # 
Show Seed Source # 

Methods

showsPrec :: Int -> Seed -> ShowS #

show :: Seed -> String #

showList :: [Seed] -> ShowS #

RandomGen Seed Source # 

Methods

next :: Seed -> (Int, Seed) #

genRange :: Seed -> (Int, Int) #

split :: Seed -> (Seed, Seed) #

Tests

type Test = TestT Identity Source #

A test monad allows the assertion of expectations.

data TestT m a Source #

A test monad transformer allows the assertion of expectations.

Instances

MonadTrans TestT Source # 

Methods

lift :: Monad m => m a -> TestT m a #

MonadTransControl TestT Source # 

Associated Types

type StT (TestT :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run TestT -> m a) -> TestT m a #

restoreT :: Monad m => m (StT TestT a) -> TestT m a #

Distributive TestT Source # 

Associated Types

type Transformer (f :: (* -> *) -> * -> *) (TestT :: (* -> *) -> * -> *) (m :: * -> *) :: Constraint Source #

Methods

distribute :: Transformer f TestT m => TestT (f m) a -> f (TestT m) a Source #

MonadBase b m => MonadBase b (TestT m) Source # 

Methods

liftBase :: b α -> TestT m α #

MonadBaseControl b m => MonadBaseControl b (TestT m) Source # 

Associated Types

type StM (TestT m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (TestT m) b -> b a) -> TestT m a #

restoreM :: StM (TestT m) a -> TestT m a #

MonadState s m => MonadState s (TestT m) Source # 

Methods

get :: TestT m s #

put :: s -> TestT m () #

state :: (s -> (a, s)) -> TestT m a #

MonadReader r m => MonadReader r (TestT m) Source # 

Methods

ask :: TestT m r #

local :: (r -> r) -> TestT m a -> TestT m a #

reader :: (r -> a) -> TestT m a #

MonadError e m => MonadError e (TestT m) Source # 

Methods

throwError :: e -> TestT m a #

catchError :: TestT m a -> (e -> TestT m a) -> TestT m a #

Monad m => Monad (TestT m) Source # 

Methods

(>>=) :: TestT m a -> (a -> TestT m b) -> TestT m b #

(>>) :: TestT m a -> TestT m b -> TestT m b #

return :: a -> TestT m a #

fail :: String -> TestT m a #

Functor m => Functor (TestT m) Source # 

Methods

fmap :: (a -> b) -> TestT m a -> TestT m b #

(<$) :: a -> TestT m b -> TestT m a #

Monad m => Applicative (TestT m) Source # 

Methods

pure :: a -> TestT m a #

(<*>) :: TestT m (a -> b) -> TestT m a -> TestT m b #

liftA2 :: (a -> b -> c) -> TestT m a -> TestT m b -> TestT m c #

(*>) :: TestT m a -> TestT m b -> TestT m b #

(<*) :: TestT m a -> TestT m b -> TestT m a #

MonadIO m => MonadIO (TestT m) Source # 

Methods

liftIO :: IO a -> TestT m a #

MonadCatch m => MonadCatch (TestT m) Source # 

Methods

catch :: Exception e => TestT m a -> (e -> TestT m a) -> TestT m a #

MonadThrow m => MonadThrow (TestT m) Source # 

Methods

throwM :: Exception e => e -> TestT m a #

PrimMonad m => PrimMonad (TestT m) Source # 

Associated Types

type PrimState (TestT m :: * -> *) :: * #

Methods

primitive :: (State# (PrimState (TestT m)) -> (#TupleRep [RuntimeRep], LiftedRep, State# (PrimState (TestT m)), a#)) -> TestT m a #

MonadResource m => MonadResource (TestT m) Source # 

Methods

liftResourceT :: ResourceT IO a -> TestT m a #

Monad m => MonadTest (TestT m) Source # 

Methods

liftTest :: Test a -> TestT m a Source #

MFunctor * TestT Source # 

Methods

hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b #

type StT TestT a Source # 
type StT TestT a = (Either Failure a, [Log])
type Transformer t TestT m Source # 
type PrimState (TestT m) Source # 
type StM (TestT m) a Source # 
type StM (TestT m) a = ComposeSt TestT m a

class Monad m => MonadTest m where Source #

Minimal complete definition

liftTest

Methods

liftTest :: Test a -> m a Source #

Instances

MonadTest m => MonadTest (MaybeT m) Source # 

Methods

liftTest :: Test a -> MaybeT m a Source #

MonadTest m => MonadTest (ResourceT m) Source # 

Methods

liftTest :: Test a -> ResourceT m a Source #

Monad m => MonadTest (TestT m) Source # 

Methods

liftTest :: Test a -> TestT m a Source #

Monad m => MonadTest (PropertyT m) Source # 

Methods

liftTest :: Test a -> PropertyT m a Source #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) Source # 

Methods

liftTest :: Test a -> WriterT w m a Source #

MonadTest m => MonadTest (StateT s m) Source # 

Methods

liftTest :: Test a -> StateT s m a Source #

MonadTest m => MonadTest (ExceptT x m) Source # 

Methods

liftTest :: Test a -> ExceptT x m a Source #

MonadTest m => MonadTest (IdentityT * m) Source # 

Methods

liftTest :: Test a -> IdentityT * m a Source #

MonadTest m => MonadTest (StateT s m) Source # 

Methods

liftTest :: Test a -> StateT s m a Source #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) Source # 

Methods

liftTest :: Test a -> WriterT w m a Source #

MonadTest m => MonadTest (ReaderT * r m) Source # 

Methods

liftTest :: Test a -> ReaderT * r m a Source #

MonadTest m => MonadTest (ContT * r m) Source # 

Methods

liftTest :: Test a -> ContT * r m a Source #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) Source # 

Methods

liftTest :: Test a -> RWST r w s m a Source #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) Source # 

Methods

liftTest :: Test a -> RWST r w s m a Source #

annotate :: (MonadTest m, HasCallStack) => String -> m () Source #

Annotates the source code with a message that might be useful for debugging a test failure.

annotateShow :: (MonadTest m, Show a, HasCallStack) => a -> m () Source #

Annotates the source code with a value that might be useful for debugging a test failure.

footnote :: MonadTest m => String -> m () Source #

Logs a message to be displayed as additional information in the footer of the failure report.

footnoteShow :: (MonadTest m, Show a) => a -> m () Source #

Logs a value to be displayed as additional information in the footer of the failure report.

success :: MonadTest m => m () Source #

Another name for pure ().

failure :: (MonadTest m, HasCallStack) => m a Source #

Causes a test to fail.

assert :: (MonadTest m, HasCallStack) => Bool -> m () Source #

Fails the test if the condition provided is False.

(===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 Source #

Fails the test if the two arguments provided are not equal.

(/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 Source #

Fails the test if the two arguments provided are equal.

tripping :: (MonadTest m, Applicative f, Show b, Show (f a), Eq (f a), HasCallStack) => a -> (a -> b) -> (b -> f a) -> m () Source #

Test that a pair of encode / decode functions are compatible.

eval :: (MonadTest m, HasCallStack) => a -> m a Source #

Fails the test if the value throws an exception when evaluated to weak head normal form (WHNF).

evalM :: (MonadTest m, MonadCatch m, HasCallStack) => m a -> m a Source #

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.

evalIO :: (MonadTest m, MonadIO m, HasCallStack) => IO a -> m a Source #

Fails the test if the IO action throws an exception.

The benefit of using this over liftIO is that the location of the exception will be shown in the output.

evalEither :: (MonadTest m, Show x, HasCallStack) => Either x a -> m a Source #

Fails the test if the Either is Left, otherwise returns the value in the Right.

evalExceptT :: (MonadTest m, Show x, HasCallStack) => ExceptT x m a -> m a Source #

Fails the test if the ExceptT is Left, otherwise returns the value in the Right.

State Machine Tests

data Command n m (state :: (* -> *) -> *) Source #

The specification for the expected behaviour of an Action.

Constructors

(HTraversable input, Show (input Symbolic), Typeable output) => Command 

Fields

  • commandGen :: state Symbolic -> Maybe (n (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 output

    Executes 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.

data Callback input output state Source #

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. Ord1 v => state v -> input v -> Var output v -> state v)

Updates the model state, given the input and output of the command. Note that this function is polymorphic in the type of values. This is because it must work over Symbolic values when we are generating actions, and Concrete values when we are executing them.

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.

data Action m (state :: (* -> *) -> *) Source #

An instantiation of a Command which can be executed, and its effect evaluated.

Instances

Show (Action m state) Source # 

Methods

showsPrec :: Int -> Action m state -> ShowS #

show :: Action m state -> String #

showList :: [Action m state] -> ShowS #

data Sequential m state Source #

A sequence of actions to execute.

Constructors

Sequential 

Fields

Instances

Show (Sequential m state) Source # 

Methods

showsPrec :: Int -> Sequential m state -> ShowS #

show :: Sequential m state -> String #

showList :: [Sequential m state] -> ShowS #

data Parallel m state Source #

A sequential prefix of actions to execute, with two branches to execute in parallel.

Constructors

Parallel 

Fields

Instances

Show (Parallel m state) Source # 

Methods

showsPrec :: Int -> Parallel m state -> ShowS #

show :: Parallel m state -> String #

showList :: [Parallel m state] -> ShowS #

executeSequential :: (MonadTest m, MonadCatch m, HasCallStack) => (forall v. state v) -> Sequential m state -> m () Source #

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.

executeParallel :: (MonadTest m, MonadCatch m, MonadBaseControl IO m, HasCallStack) => (forall v. state v) -> Parallel m state -> m () Source #

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.

data Var a v Source #

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.

Constructors

Var (v a) 

Instances

HTraversable (Var a) Source # 

Methods

htraverse :: Applicative f => (forall b. g b -> f (h b)) -> Var a g -> f (Var a h) Source #

(Eq a, Eq1 v) => Eq (Var a v) Source # 

Methods

(==) :: Var a v -> Var a v -> Bool #

(/=) :: Var a v -> Var a v -> Bool #

(Ord a, Ord1 v) => Ord (Var a v) Source # 

Methods

compare :: Var a v -> Var a v -> Ordering #

(<) :: Var a v -> Var a v -> Bool #

(<=) :: Var a v -> Var a v -> Bool #

(>) :: Var a v -> Var a v -> Bool #

(>=) :: Var a v -> Var a v -> Bool #

max :: Var a v -> Var a v -> Var a v #

min :: Var a v -> Var a v -> Var a v #

(Show a, Show1 v) => Show (Var a v) Source # 

Methods

showsPrec :: Int -> Var a v -> ShowS #

show :: Var a v -> String #

showList :: [Var a v] -> ShowS #

concrete :: Var a Concrete -> a Source #

Take the value from a concrete variable.

opaque :: Var (Opaque a) Concrete -> a Source #

Take the value from an opaque concrete variable.

data Symbolic a Source #

Symbolic values.

Instances

Eq1 Symbolic Source # 

Methods

liftEq :: (a -> b -> Bool) -> Symbolic a -> Symbolic b -> Bool #

Ord1 Symbolic Source # 

Methods

liftCompare :: (a -> b -> Ordering) -> Symbolic a -> Symbolic b -> Ordering #

Show1 Symbolic Source # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Symbolic a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Symbolic a] -> ShowS #

Eq (Symbolic a) Source # 

Methods

(==) :: Symbolic a -> Symbolic a -> Bool #

(/=) :: Symbolic a -> Symbolic a -> Bool #

Ord (Symbolic a) Source # 

Methods

compare :: Symbolic a -> Symbolic a -> Ordering #

(<) :: Symbolic a -> Symbolic a -> Bool #

(<=) :: Symbolic a -> Symbolic a -> Bool #

(>) :: Symbolic a -> Symbolic a -> Bool #

(>=) :: Symbolic a -> Symbolic a -> Bool #

max :: Symbolic a -> Symbolic a -> Symbolic a #

min :: Symbolic a -> Symbolic a -> Symbolic a #

Show (Symbolic a) Source # 

Methods

showsPrec :: Int -> Symbolic a -> ShowS #

show :: Symbolic a -> String #

showList :: [Symbolic a] -> ShowS #

newtype Concrete a where Source #

Concrete values.

Constructors

Concrete :: a -> Concrete a 

Instances

Functor Concrete Source # 

Methods

fmap :: (a -> b) -> Concrete a -> Concrete b #

(<$) :: a -> Concrete b -> Concrete a #

Foldable Concrete Source # 

Methods

fold :: Monoid m => Concrete m -> m #

foldMap :: Monoid m => (a -> m) -> Concrete a -> m #

foldr :: (a -> b -> b) -> b -> Concrete a -> b #

foldr' :: (a -> b -> b) -> b -> Concrete a -> b #

foldl :: (b -> a -> b) -> b -> Concrete a -> b #

foldl' :: (b -> a -> b) -> b -> Concrete a -> b #

foldr1 :: (a -> a -> a) -> Concrete a -> a #

foldl1 :: (a -> a -> a) -> Concrete a -> a #

toList :: Concrete a -> [a] #

null :: Concrete a -> Bool #

length :: Concrete a -> Int #

elem :: Eq a => a -> Concrete a -> Bool #

maximum :: Ord a => Concrete a -> a #

minimum :: Ord a => Concrete a -> a #

sum :: Num a => Concrete a -> a #

product :: Num a => Concrete a -> a #

Traversable Concrete Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Concrete a -> f (Concrete b) #

sequenceA :: Applicative f => Concrete (f a) -> f (Concrete a) #

mapM :: Monad m => (a -> m b) -> Concrete a -> m (Concrete b) #

sequence :: Monad m => Concrete (m a) -> m (Concrete a) #

Eq1 Concrete Source # 

Methods

liftEq :: (a -> b -> Bool) -> Concrete a -> Concrete b -> Bool #

Ord1 Concrete Source # 

Methods

liftCompare :: (a -> b -> Ordering) -> Concrete a -> Concrete b -> Ordering #

Show1 Concrete Source # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Concrete a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Concrete a] -> ShowS #

Eq a => Eq (Concrete a) Source # 

Methods

(==) :: Concrete a -> Concrete a -> Bool #

(/=) :: Concrete a -> Concrete a -> Bool #

Ord a => Ord (Concrete a) Source # 

Methods

compare :: Concrete a -> Concrete a -> Ordering #

(<) :: Concrete a -> Concrete a -> Bool #

(<=) :: Concrete a -> Concrete a -> Bool #

(>) :: Concrete a -> Concrete a -> Bool #

(>=) :: Concrete a -> Concrete a -> Bool #

max :: Concrete a -> Concrete a -> Concrete a #

min :: Concrete a -> Concrete a -> Concrete a #

Show a => Show (Concrete a) Source # 

Methods

showsPrec :: Int -> Concrete a -> ShowS #

show :: Concrete a -> String #

showList :: [Concrete a] -> ShowS #

newtype Opaque a Source #

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)

Constructors

Opaque 

Fields

Instances

Eq a => Eq (Opaque a) Source # 

Methods

(==) :: Opaque a -> Opaque a -> Bool #

(/=) :: Opaque a -> Opaque a -> Bool #

Ord a => Ord (Opaque a) Source # 

Methods

compare :: Opaque a -> Opaque a -> Ordering #

(<) :: Opaque a -> Opaque a -> Bool #

(<=) :: Opaque a -> Opaque a -> Bool #

(>) :: Opaque a -> Opaque a -> Bool #

(>=) :: Opaque a -> Opaque a -> Bool #

max :: Opaque a -> Opaque a -> Opaque a #

min :: Opaque a -> Opaque a -> Opaque a #

Show (Opaque a) Source # 

Methods

showsPrec :: Int -> Opaque a -> ShowS #

show :: Opaque a -> String #

showList :: [Opaque a] -> ShowS #

Transformers

distribute :: (Distributive g, Transformer f g m) => g (f m) a -> f (g m) a Source #

Distribute one monad transformer over another.

Functors

class HTraversable t where Source #

Higher-order traversable functors.

This is used internally to make symbolic variables concrete given an Environment.

Minimal complete definition

htraverse

Methods

htraverse :: Applicative f => (forall a. g a -> f (h a)) -> t g -> f (t h) Source #

Instances

HTraversable (Var a) Source # 

Methods

htraverse :: Applicative f => (forall b. g b -> f (h b)) -> Var a g -> f (Var a h) Source #

class Eq1 (f :: * -> *) #

Lifting of the Eq class to unary type constructors.

Since: 4.9.0.0

Minimal complete definition

liftEq

Instances

Eq1 []

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> [a] -> [b] -> Bool #

Eq1 Maybe

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Maybe a -> Maybe b -> Bool #

Eq1 NonEmpty

Since: 4.10.0.0

Methods

liftEq :: (a -> b -> Bool) -> NonEmpty a -> NonEmpty b -> Bool #

Eq1 Identity

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Identity a -> Identity b -> Bool #

Eq1 IntMap 

Methods

liftEq :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool #

Eq1 Tree 

Methods

liftEq :: (a -> b -> Bool) -> Tree a -> Tree b -> Bool #

Eq1 Seq 

Methods

liftEq :: (a -> b -> Bool) -> Seq a -> Seq b -> Bool #

Eq1 Set 

Methods

liftEq :: (a -> b -> Bool) -> Set a -> Set b -> Bool #

Eq1 Concrete # 

Methods

liftEq :: (a -> b -> Bool) -> Concrete a -> Concrete b -> Bool #

Eq1 Symbolic # 

Methods

liftEq :: (a -> b -> Bool) -> Symbolic a -> Symbolic b -> Bool #

Eq a => Eq1 (Either a)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Either a a -> Either a b -> Bool #

Eq a => Eq1 ((,) a)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> (a, a) -> (a, b) -> Bool #

Eq1 (Proxy *)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Proxy * a -> Proxy * b -> Bool #

Eq k => Eq1 (Map k) 

Methods

liftEq :: (a -> b -> Bool) -> Map k a -> Map k b -> Bool #

Eq1 m => Eq1 (ListT m) 

Methods

liftEq :: (a -> b -> Bool) -> ListT m a -> ListT m b -> Bool #

Eq1 m => Eq1 (MaybeT m) 

Methods

liftEq :: (a -> b -> Bool) -> MaybeT m a -> MaybeT m b -> Bool #

Eq a => Eq1 (Const * a)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Const * a a -> Const * a b -> Bool #

(Eq w, Eq1 m) => Eq1 (WriterT w m) 

Methods

liftEq :: (a -> b -> Bool) -> WriterT w m a -> WriterT w m b -> Bool #

(Eq e, Eq1 m) => Eq1 (ExceptT e m) 

Methods

liftEq :: (a -> b -> Bool) -> ExceptT e m a -> ExceptT e m b -> Bool #

(Eq e, Eq1 m) => Eq1 (ErrorT e m) 

Methods

liftEq :: (a -> b -> Bool) -> ErrorT e m a -> ErrorT e m b -> Bool #

Eq1 f => Eq1 (IdentityT * f) 

Methods

liftEq :: (a -> b -> Bool) -> IdentityT * f a -> IdentityT * f b -> Bool #

(Eq w, Eq1 m) => Eq1 (WriterT w m) 

Methods

liftEq :: (a -> b -> Bool) -> WriterT w m a -> WriterT w m b -> Bool #

(Eq1 f, Eq1 g) => Eq1 (Product * f g)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Product * f g a -> Product * f g b -> Bool #

(Eq1 f, Eq1 g) => Eq1 (Sum * f g)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Sum * f g a -> Sum * f g b -> Bool #

(Eq1 f, Eq1 g) => Eq1 (Compose * * f g)

Since: 4.9.0.0

Methods

liftEq :: (a -> b -> Bool) -> Compose * * f g a -> Compose * * f g b -> Bool #

eq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool #

Lift the standard (==) function through the type constructor.

Since: 4.9.0.0

class Eq1 f => Ord1 (f :: * -> *) #

Lifting of the Ord class to unary type constructors.

Since: 4.9.0.0

Minimal complete definition

liftCompare

Instances

Ord1 []

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> [a] -> [b] -> Ordering #

Ord1 Maybe

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Maybe a -> Maybe b -> Ordering #

Ord1 NonEmpty

Since: 4.10.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> NonEmpty a -> NonEmpty b -> Ordering #

Ord1 Identity

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Identity a -> Identity b -> Ordering #

Ord1 IntMap 

Methods

liftCompare :: (a -> b -> Ordering) -> IntMap a -> IntMap b -> Ordering #

Ord1 Tree 

Methods

liftCompare :: (a -> b -> Ordering) -> Tree a -> Tree b -> Ordering #

Ord1 Seq 

Methods

liftCompare :: (a -> b -> Ordering) -> Seq a -> Seq b -> Ordering #

Ord1 Set 

Methods

liftCompare :: (a -> b -> Ordering) -> Set a -> Set b -> Ordering #

Ord1 Concrete # 

Methods

liftCompare :: (a -> b -> Ordering) -> Concrete a -> Concrete b -> Ordering #

Ord1 Symbolic # 

Methods

liftCompare :: (a -> b -> Ordering) -> Symbolic a -> Symbolic b -> Ordering #

Ord a => Ord1 (Either a)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Either a a -> Either a b -> Ordering #

Ord a => Ord1 ((,) a)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> (a, a) -> (a, b) -> Ordering #

Ord1 (Proxy *)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Proxy * a -> Proxy * b -> Ordering #

Ord k => Ord1 (Map k) 

Methods

liftCompare :: (a -> b -> Ordering) -> Map k a -> Map k b -> Ordering #

Ord1 m => Ord1 (ListT m) 

Methods

liftCompare :: (a -> b -> Ordering) -> ListT m a -> ListT m b -> Ordering #

Ord1 m => Ord1 (MaybeT m) 

Methods

liftCompare :: (a -> b -> Ordering) -> MaybeT m a -> MaybeT m b -> Ordering #

Ord a => Ord1 (Const * a)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Const * a a -> Const * a b -> Ordering #

(Ord w, Ord1 m) => Ord1 (WriterT w m) 

Methods

liftCompare :: (a -> b -> Ordering) -> WriterT w m a -> WriterT w m b -> Ordering #

(Ord e, Ord1 m) => Ord1 (ExceptT e m) 

Methods

liftCompare :: (a -> b -> Ordering) -> ExceptT e m a -> ExceptT e m b -> Ordering #

(Ord e, Ord1 m) => Ord1 (ErrorT e m) 

Methods

liftCompare :: (a -> b -> Ordering) -> ErrorT e m a -> ErrorT e m b -> Ordering #

Ord1 f => Ord1 (IdentityT * f) 

Methods

liftCompare :: (a -> b -> Ordering) -> IdentityT * f a -> IdentityT * f b -> Ordering #

(Ord w, Ord1 m) => Ord1 (WriterT w m) 

Methods

liftCompare :: (a -> b -> Ordering) -> WriterT w m a -> WriterT w m b -> Ordering #

(Ord1 f, Ord1 g) => Ord1 (Product * f g)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Product * f g a -> Product * f g b -> Ordering #

(Ord1 f, Ord1 g) => Ord1 (Sum * f g)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Sum * f g a -> Sum * f g b -> Ordering #

(Ord1 f, Ord1 g) => Ord1 (Compose * * f g)

Since: 4.9.0.0

Methods

liftCompare :: (a -> b -> Ordering) -> Compose * * f g a -> Compose * * f g b -> Ordering #

compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering #

Lift the standard compare function through the type constructor.

Since: 4.9.0.0

class Show1 (f :: * -> *) #

Lifting of the Show class to unary type constructors.

Since: 4.9.0.0

Minimal complete definition

liftShowsPrec

Instances

Show1 []

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> [a] -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [[a]] -> ShowS #

Show1 Maybe

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Maybe a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Maybe a] -> ShowS #

Show1 NonEmpty

Since: 4.10.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NonEmpty a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NonEmpty a] -> ShowS #

Show1 Identity

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Identity a] -> ShowS #

Show1 IntMap 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> IntMap a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [IntMap a] -> ShowS #

Show1 Tree 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tree a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tree a] -> ShowS #

Show1 Seq 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Seq a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Seq a] -> ShowS #

Show1 Set 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Set a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Set a] -> ShowS #

Show1 Concrete # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Concrete a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Concrete a] -> ShowS #

Show1 Symbolic # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Symbolic a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Symbolic a] -> ShowS #

Show a => Show1 (Either a)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Either a a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Either a a] -> ShowS #

Show a => Show1 ((,) a)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> (a, a) -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [(a, a)] -> ShowS #

Show1 (Proxy *)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Proxy * a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Proxy * a] -> ShowS #

Show k => Show1 (Map k) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Map k a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Map k a] -> ShowS #

Show1 m => Show1 (ListT m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ListT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ListT m a] -> ShowS #

Show1 m => Show1 (MaybeT m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeT m a] -> ShowS #

Show1 m => Show1 (Node m) # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Node m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Node m a] -> ShowS #

Show1 m => Show1 (Tree m) # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tree m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tree m a] -> ShowS #

Show a => Show1 (Const * a)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Const * a a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Const * a a] -> ShowS #

(Show w, Show1 m) => Show1 (WriterT w m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WriterT w m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WriterT w m a] -> ShowS #

(Show e, Show1 m) => Show1 (ExceptT e m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExceptT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExceptT e m a] -> ShowS #

(Show e, Show1 m) => Show1 (ErrorT e m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ErrorT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ErrorT e m a] -> ShowS #

Show1 f => Show1 (IdentityT * f) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> IdentityT * f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [IdentityT * f a] -> ShowS #

(Show w, Show1 m) => Show1 (WriterT w m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WriterT w m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WriterT w m a] -> ShowS #

(Show1 f, Show1 g) => Show1 (Product * f g)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Product * f g a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Product * f g a] -> ShowS #

(Show1 f, Show1 g) => Show1 (Sum * f g)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Sum * f g a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Sum * f g a] -> ShowS #

(Show1 f, Show1 g) => Show1 (Compose * * f g)

Since: 4.9.0.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Compose * * f g a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Compose * * f g a] -> ShowS #

showsPrec1 :: (Show1 f, Show a) => Int -> f a -> ShowS #

Lift the standard showsPrec and showList functions through the type constructor.

Since: 4.9.0.0