smallcheck-1.2.1.1: A property-based testing library

Copyright | (c) Colin Runciman et al.
License | BSD3
Maintainer | Roman Cheplyaka <roma@ro-che.info>
Safe Haskell | Safe
Language | Haskell2010

Test.SmallCheck.Series

Contents

- Generic instances
- Data Generators
  - What does `consN` do, exactly?
- Function Generators
  - What does altsN do, exactly?
- Basic definitions
- Generic implementations
- Convenient wrappers
- Other useful definitions
- Orphan instances

Description

You need this module if you want to generate test values of your own types.

You'll typically need the following extensions:

    {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}

SmallCheck itself defines data generators for all the data types used by the Prelude.

In order to generate values and functions of your own types, you need to make them instances of `Serial` (for values) and `CoSerial` (for functions). There are two main ways to do so: using Generics or writing the instances by hand.

Synopsis

- cons0 :: forall a (m :: Type -> Type). a -> Series m a
- cons1 :: forall (m :: Type -> Type) a b. Serial m a => (a -> b) -> Series m b
- cons2 :: forall (m :: Type -> Type) a b c. (Serial m a, Serial m b) => (a -> b -> c) -> Series m c
- cons3 :: forall (m :: Type -> Type) a b c d. (Serial m a, Serial m b, Serial m c) => (a -> b -> c -> d) -> Series m d
- cons4 :: forall (m :: Type -> Type) a b c d e. (Serial m a, Serial m b, Serial m c, Serial m d) => (a -> b -> c -> d -> e) -> Series m e
- cons5 :: forall (m :: Type -> Type) a b c d e f. (Serial m a, Serial m b, Serial m c, Serial m d, Serial m e) => (a -> b -> c -> d -> e -> f) -> Series m f
- cons6 :: forall (m :: Type -> Type) a b c d e f g. (Serial m a, Serial m b, Serial m c, Serial m d, Serial m e, Serial m f) => (a -> b -> c -> d -> e -> f -> g) -> Series m g
- newtypeCons :: forall (m :: Type -> Type) a b. Serial m a => (a -> b) -> Series m b
- alts0 :: forall (m :: Type -> Type) a. Series m a -> Series m a
- alts1 :: forall (m :: Type -> Type) a b. CoSerial m a => Series m b -> Series m (a -> b)
- alts2 :: forall (m :: Type -> Type) a b c. (CoSerial m a, CoSerial m b) => Series m c -> Series m (a -> b -> c)
- alts3 :: forall (m :: Type -> Type) a b c d. (CoSerial m a, CoSerial m b, CoSerial m c) => Series m d -> Series m (a -> b -> c -> d)
- alts4 :: forall (m :: Type -> Type) a b c d e. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d) => Series m e -> Series m (a -> b -> c -> d -> e)
- alts5 :: forall (m :: Type -> Type) a b c d e f. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e) => Series m f -> Series m (a -> b -> c -> d -> e -> f)
- alts6 :: forall (m :: Type -> Type) a b c d e f g. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e, CoSerial m f) => Series m g -> Series m (a -> b -> c -> d -> e -> f -> g)
- newtypeAlts :: forall (m :: Type -> Type) a b. CoSerial m a => Series m b -> Series m (a -> b)
- type Depth = Int
- data Series (m :: Type -> Type) a
- class Monad m => Serial (m :: Type -> Type) a where
  - series :: Series m a
- class Monad m => CoSerial (m :: Type -> Type) a where
  - coseries :: Series m b -> Series m (a -> b)
- genericSeries :: forall (m :: Type -> Type) a. (Monad m, Generic a, GSerial m (Rep a)) => Series m a
- genericCoseries :: forall (m :: Type -> Type) a b. (Monad m, Generic a, GCoSerial m (Rep a)) => Series m b -> Series m (a -> b)
- newtype Positive a = Positive {
  - getPositive :: a
  }
- newtype NonNegative a = NonNegative {
  - getNonNegative :: a
  }
- newtype NonZero a = NonZero {
  - getNonZero :: a
  }
- newtype NonEmpty a = NonEmpty {
  - getNonEmpty :: [a]
  }
- (\/) :: forall (m :: Type -> Type) a. Monad m => Series m a -> Series m a -> Series m a
- (><) :: forall (m :: Type -> Type) a b. Monad m => Series m a -> Series m b -> Series m (a, b)
- (<~>) :: forall (m :: Type -> Type) a b. Monad m => Series m (a -> b) -> Series m a -> Series m b
- (>>-) :: MonadLogic m => m a -> (a -> m b) -> m b
- localDepth :: forall (m :: Type -> Type) a. (Depth -> Depth) -> Series m a -> Series m a
- decDepth :: forall (m :: Type -> Type) a. Series m a -> Series m a
- getDepth :: forall (m :: Type -> Type). Series m Depth
- generate :: forall a (m :: Type -> Type). (Depth -> [a]) -> Series m a
- limit :: forall (m :: Type -> Type) a. Monad m => Int -> Series m a -> Series m a
- listSeries :: Serial Identity a => Depth -> [a]
- list :: Depth -> Series Identity a -> [a]
- listM :: Applicative m => Depth -> Series m a -> m [a]
- fixDepth :: forall (m :: Type -> Type) a. Series m a -> Series m (Series m a)
- decDepthChecked :: forall (m :: Type -> Type) a. Series m a -> Series m a -> Series m a
- constM :: Monad m => m b -> m (a -> b)

# Generic instances

The easiest way to create the necessary instances is to use GHC generics (available starting with GHC 7.2.1).

Here's a complete example:

    {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
    {-# LANGUAGE DeriveGeneric #-}

    import Test.SmallCheck.Series
    import GHC.Generics

    data Tree a = Null | Fork (Tree a) a (Tree a)
        deriving Generic

    instance Serial m a => Serial m (Tree a)

Here we enable the `DeriveGeneric` extension which allows to derive `Generic` instance for our data type. Then we declare that `Tree` `a` is an instance of `Serial`, but do not provide any definitions. This causes GHC to use the default definitions that use the `Generic` instance.

One minor limitation of generic instances is that there's currently no way to distinguish newtypes and datatypes. Thus, newtype constructors will also count as one level of depth.

# Data Generators

Writing `Serial` instances for application-specific types is straightforward. You need to define a `series` generator, typically using `consN` family of generic combinators where N is constructor arity.

For example:

    data Tree a = Null | Fork (Tree a) a (Tree a)

    instance Serial m a => Serial m (Tree a) where
      series = cons0 Null \/ cons3 Fork

For newtypes use `newtypeCons` instead of `cons1`. The difference is that `cons1` is counts as one level of depth, while `newtypeCons` doesn't affect the depth.

    newtype Light a = Light a

    instance Serial m a => Serial m (Light a) where
      series = newtypeCons Light

For data types with more than 6 fields define `consN` as

    consN f = decDepth $
      f <$> series
        <~> series
        <~> series
        <~> ...    {- series repeated N times in total -}

## What does `consN` do, exactly?

`consN` has type `(Serial t₁, ..., Serial tₙ) => (t₁ -> ... -> tₙ -> t) -> Series t`.

`consN` `f` is a series which, for a given depth \(d > 0\), produces values of the form

    f x₁ ... xₙ

where `xₖ` ranges over all values of type `tₖ` of depth up to \(d-1\) (as defined by the `series` functions for `tₖ`).

`consN` functions also ensure that xₖ are enumerated in the breadth-first order. Thus, combinations of smaller depth come first (assuming the same is true for `tₖ`).

If \(d \le 0\), no values are produced.

cons0 :: forall a (m :: Type -> Type). a -> Series m a Source #

Since: 1.0

cons1 :: forall (m :: Type -> Type) a b. Serial m a => (a -> b) -> Series m b Source #

Since: 1.0

cons2 :: forall (m :: Type -> Type) a b c. (Serial m a, Serial m b) => (a -> b -> c) -> Series m c Source #

Since: 1.0

cons3 :: forall (m :: Type -> Type) a b c d. (Serial m a, Serial m b, Serial m c) => (a -> b -> c -> d) -> Series m d Source #

Since: 1.0

cons4 :: forall (m :: Type -> Type) a b c d e. (Serial m a, Serial m b, Serial m c, Serial m d) => (a -> b -> c -> d -> e) -> Series m e Source #

Since: 1.0

cons5 :: forall (m :: Type -> Type) a b c d e f. (Serial m a, Serial m b, Serial m c, Serial m d, Serial m e) => (a -> b -> c -> d -> e -> f) -> Series m f Source #

Since: 1.2.0

cons6 :: forall (m :: Type -> Type) a b c d e f g. (Serial m a, Serial m b, Serial m c, Serial m d, Serial m e, Serial m f) => (a -> b -> c -> d -> e -> f -> g) -> Series m g Source #

Since: 1.2.0

newtypeCons :: forall (m :: Type -> Type) a b. Serial m a => (a -> b) -> Series m b Source #

Same as `cons1`, but preserves the depth.

Since: 1.0

# Function Generators

To generate functions of an application-specific argument type, make the type an instance of `CoSerial`.

Again there is a standard pattern, this time using the `altsN` combinators where again N is constructor arity. Here are `Tree` and `Light` instances:

    instance CoSerial m a => CoSerial m (Tree a) where
      coseries rs =
        alts0 rs >>- \z ->
        alts3 rs >>- \f ->
        return $ \t ->
          case t of
            Null -> z
            Fork t1 x t2 -> f t1 x t2

    instance CoSerial m a => CoSerial m (Light a) where
      coseries rs =
        newtypeAlts rs >>- \f ->
        return $ \l ->
          case l of
            Light x -> f x

For data types with more than 6 fields define `altsN` as

    altsN rs = do
      rs <- fixDepth rs
      decDepthChecked
        (constM $ constM $ ... $ constM rs)
        (coseries $ coseries $ ... $ coseries rs)
        {- constM and coseries are repeated N times each -}

## What does altsN do, exactly?

`altsN` has type `(Serial t₁, ..., Serial tₙ) => Series t -> Series (t₁ -> ... -> tₙ -> t)`.

`altsN` `s` is a series which, for a given depth \( d \), produces functions of type

    t₁ -> ... -> tₙ -> t

If \( d \le 0 \), these are constant functions, one for each value produced by `s`.

If \( d > 0 \), these functions inspect each of their arguments up to the depth \( d-1 \) (as defined by the `coseries` functions for the corresponding types) and return values produced by `s`. The depth to which the values are enumerated does not depend on the depth of inspection.

alts0 :: forall (m :: Type -> Type) a. Series m a -> Series m a Source #

Since: 1.0

alts1 :: forall (m :: Type -> Type) a b. CoSerial m a => Series m b -> Series m (a -> b) Source #

Since: 1.0

alts2 :: forall (m :: Type -> Type) a b c. (CoSerial m a, CoSerial m b) => Series m c -> Series m (a -> b -> c) Source #

Since: 1.0

alts3 :: forall (m :: Type -> Type) a b c d. (CoSerial m a, CoSerial m b, CoSerial m c) => Series m d -> Series m (a -> b -> c -> d) Source #

Since: 1.0

alts4 :: forall (m :: Type -> Type) a b c d e. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d) => Series m e -> Series m (a -> b -> c -> d -> e) Source #

Since: 1.0

alts5 :: forall (m :: Type -> Type) a b c d e f. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e) => Series m f -> Series m (a -> b -> c -> d -> e -> f) Source #

Since: 1.2.0

alts6 :: forall (m :: Type -> Type) a b c d e f g. (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e, CoSerial m f) => Series m g -> Series m (a -> b -> c -> d -> e -> f -> g) Source #

Since: 1.2.0

newtypeAlts :: forall (m :: Type -> Type) a b. CoSerial m a => Series m b -> Series m (a -> b) Source #

Same as `alts1`, but preserves the depth.

Since: 1.0

# Basic definitions

type Depth = Int Source #

Maximum depth of generated test values.

For data values, it is the depth of nested constructor applications.

For functional values, it is both the depth of nested case analysis and the depth of results.

Since: 0.6

data Series (m :: Type -> Type) a Source #

`Series` is a `MonadLogic` action that enumerates values of a certain type, up to some depth.

The depth bound is tracked in the `Series` monad and can be extracted using `getDepth` and changed using `localDepth`.

To manipulate series at the lowest level you can use its `Monad`, `MonadPlus` and `MonadLogic` instances. This module provides some higher-level combinators which simplify creating series.

A proper `Series` should be monotonic with respect to the depth — i.e. `localDepth` `(+1)` `s` should emit all the values that `s` emits (and possibly some more).

It is also desirable that values of smaller depth come before the values of greater depth.

Since: 1.0

#### Instances

Instances details

MonadTrans Series Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods lift :: Monad m => m a -> Series m a Source #
Alternative (Series m) Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods empty :: Series m a Source # (<|>) :: Series m a -> Series m a -> Series m a Source # some :: Series m a -> Series m [a] Source # many :: Series m a -> Series m [a] Source #
Applicative (Series m) Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods pure :: a -> Series m a Source # (<*>) :: Series m (a -> b) -> Series m a -> Series m b Source # liftA2 :: (a -> b -> c) -> Series m a -> Series m b -> Series m c Source # (*>) :: Series m a -> Series m b -> Series m b Source # (<*) :: Series m a -> Series m b -> Series m a Source #
Functor (Series m) Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods fmap :: (a -> b) -> Series m a -> Series m b Source # (<$) :: a -> Series m b -> Series m a Source #
Monad (Series m) Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods (>>=) :: Series m a -> (a -> Series m b) -> Series m b Source # (>>) :: Series m a -> Series m b -> Series m b Source # return :: a -> Series m a Source #
MonadPlus (Series m) Source # |
Instance details Defined in Test.SmallCheck.SeriesMonad Methods mzero :: Series m a Source # mplus :: Series m a -> Series m a -> Series m a Source #
Monad m => MonadLogic (Series m) Source # |

Instance details

Defined in Test.SmallCheck.SeriesMonad

Methods

msplit :: Series m a -> Series m (Maybe (a, Series m a)) Source #

interleave :: Series m a -> Series m a -> Series m a Source #

(>>-) :: Series m a -> (a -> Series m b) -> Series m b Source #

once :: Series m a -> Series m a Source #

lnot :: Series m a -> Series m () Source #

ifte :: Series m a -> (a -> Series m b) -> Series m b -> Series m b Source #

class Monad m => Serial (m :: Type -> Type) a where Source #

Since: 1.0

Minimal complete definition

Nothing

Methods

series :: Series m a Source #

default series :: (Generic a, GSerial m (Rep a)) => Series m a Source #

#### Instances

Instances details

Monad m => Serial m Void Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Void Source #
Monad m => Serial m CBool Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CBool Source #
Monad m => Serial m CChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CChar Source #
Monad m => Serial m CClock Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CClock Source #
Monad m => Serial m CDouble Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CDouble Source #
Monad m => Serial m CFloat Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CFloat Source #
Monad m => Serial m CInt Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CInt Source #
Monad m => Serial m CIntMax Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CIntMax Source #
Monad m => Serial m CIntPtr Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CIntPtr Source #
Monad m => Serial m CLLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CLLong Source #
Monad m => Serial m CLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CLong Source #
Monad m => Serial m CPtrdiff Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CPtrdiff Source #
Monad m => Serial m CSChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CSChar Source #
Monad m => Serial m CSUSeconds Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CSUSeconds Source #
Monad m => Serial m CShort Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CShort Source #
Monad m => Serial m CSigAtomic Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CSigAtomic Source #
Monad m => Serial m CSize Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CSize Source #
Monad m => Serial m CTime Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CTime Source #
Monad m => Serial m CUChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUChar Source #
Monad m => Serial m CUInt Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUInt Source #
Monad m => Serial m CUIntMax Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUIntMax Source #
Monad m => Serial m CUIntPtr Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUIntPtr Source #
Monad m => Serial m CULLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CULLong Source #
Monad m => Serial m CULong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CULong Source #
Monad m => Serial m CUSeconds Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUSeconds Source #
Monad m => Serial m CUShort Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CUShort Source #
Monad m => Serial m CWchar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m CWchar Source #
Monad m => Serial m Int16 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Int16 Source #
Monad m => Serial m Int32 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Int32 Source #
Monad m => Serial m Int64 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Int64 Source #
Monad m => Serial m Int8 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Int8 Source #
Monad m => Serial m Word16 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Word16 Source #
Monad m => Serial m Word32 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Word32 Source #
Monad m => Serial m Word64 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Word64 Source #
Monad m => Serial m Word8 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Word8 Source #
Monad m => Serial m Ordering Source # | Since: 1.2.1
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Ordering Source #
Monad m => Serial m Integer Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Integer Source #
Monad m => Serial m Natural Source # | Since: 1.1.3
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Natural Source #
Monad m => Serial m () Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m () Source #
Monad m => Serial m Bool Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Bool Source #
Monad m => Serial m Char Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Char Source #
Monad m => Serial m Double Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Double Source #
Monad m => Serial m Float Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Float Source #
Monad m => Serial m Int Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Int Source #
Monad m => Serial m Word Source # | Since: 1.1.3
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m Word Source #
Serial m a => Serial m (Complex a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Complex a) Source #
Serial m a => Serial m (NonEmpty a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonEmpty a) Source #
(Integral i, Serial m i) => Serial m (Ratio i) Source # | Since: 1.1
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Ratio i) Source #
Serial m a => Serial m (NonEmpty a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonEmpty a) Source #
(Num a, Ord a, Serial m a) => Serial m (NonNegative a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonNegative a) Source #
(Num a, Ord a, Serial m a) => Serial m (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonZero a) Source #
(Num a, Ord a, Serial m a) => Serial m (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Positive a) Source #
Serial m a => Serial m (Maybe a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Maybe a) Source #
Serial m a => Serial m [a] Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m [a] Source #
(Serial m a, Serial m b) => Serial m (Either a b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Either a b) Source #
(Serial m a, Serial m b) => Serial m (a, b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a, b) Source #
(CoSerial m a, Serial m b) => Serial m (a -> b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a -> b) Source #
(Serial m a, Serial m b, Serial m c) => Serial m (a, b, c) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a, b, c) Source #
(Serial m a, Serial m b, Serial m c, Serial m d) => Serial m (a, b, c, d) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a, b, c, d) Source #
(Monad m, Serial m (f (g a))) => Serial m (Compose f g a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Compose f g a) Source #
(Serial m a, Serial m b, Serial m c, Serial m d, Serial m e) => Serial m (a, b, c, d, e) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a, b, c, d, e) Source #
(Serial m a, Serial m b, Serial m c, Serial m d, Serial m e, Serial m f) => Serial m (a, b, c, d, e, f) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (a, b, c, d, e, f) Source #

class Monad m => CoSerial (m :: Type -> Type) a where Source #

Since: 1.0

Minimal complete definition

Nothing

Methods

coseries :: Series m b -> Series m (a -> b) Source #

A proper `coseries` implementation should pass the depth unchanged to its first argument. Doing otherwise will make enumeration of curried functions non-uniform in their arguments.

default coseries :: (Generic a, GCoSerial m (Rep a)) => Series m b -> Series m (a -> b) Source #

#### Instances

Instances details

Monad m => CoSerial m Void Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Void -> b) Source #
Monad m => CoSerial m CBool Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CBool -> b) Source #
Monad m => CoSerial m CChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CChar -> b) Source #
Monad m => CoSerial m CClock Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CClock -> b) Source #
Monad m => CoSerial m CDouble Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CDouble -> b) Source #
Monad m => CoSerial m CFloat Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CFloat -> b) Source #
Monad m => CoSerial m CInt Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CInt -> b) Source #
Monad m => CoSerial m CIntMax Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CIntMax -> b) Source #
Monad m => CoSerial m CIntPtr Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CIntPtr -> b) Source #
Monad m => CoSerial m CLLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CLLong -> b) Source #
Monad m => CoSerial m CLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CLong -> b) Source #
Monad m => CoSerial m CPtrdiff Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CPtrdiff -> b) Source #
Monad m => CoSerial m CSChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CSChar -> b) Source #
Monad m => CoSerial m CSUSeconds Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CSUSeconds -> b) Source #
Monad m => CoSerial m CShort Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CShort -> b) Source #
Monad m => CoSerial m CSigAtomic Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CSigAtomic -> b) Source #
Monad m => CoSerial m CSize Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CSize -> b) Source #
Monad m => CoSerial m CTime Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CTime -> b) Source #
Monad m => CoSerial m CUChar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUChar -> b) Source #
Monad m => CoSerial m CUInt Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUInt -> b) Source #
Monad m => CoSerial m CUIntMax Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUIntMax -> b) Source #
Monad m => CoSerial m CUIntPtr Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUIntPtr -> b) Source #
Monad m => CoSerial m CULLong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CULLong -> b) Source #
Monad m => CoSerial m CULong Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CULong -> b) Source #
Monad m => CoSerial m CUSeconds Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUSeconds -> b) Source #
Monad m => CoSerial m CUShort Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CUShort -> b) Source #
Monad m => CoSerial m CWchar Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (CWchar -> b) Source #
Monad m => CoSerial m Int16 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Int16 -> b) Source #
Monad m => CoSerial m Int32 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Int32 -> b) Source #
Monad m => CoSerial m Int64 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Int64 -> b) Source #
Monad m => CoSerial m Int8 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Int8 -> b) Source #
Monad m => CoSerial m Word16 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Word16 -> b) Source #
Monad m => CoSerial m Word32 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Word32 -> b) Source #
Monad m => CoSerial m Word64 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Word64 -> b) Source #
Monad m => CoSerial m Word8 Source # | Since: 1.1.4
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Word8 -> b) Source #
Monad m => CoSerial m Ordering Source # | Since: 1.2.1
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Ordering -> b) Source #
Monad m => CoSerial m Integer Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Integer -> b) Source #
Monad m => CoSerial m Natural Source # | Since: 1.1.3
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Natural -> b) Source #
Monad m => CoSerial m () Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (() -> b) Source #
Monad m => CoSerial m Bool Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Bool -> b) Source #
Monad m => CoSerial m Char Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Char -> b) Source #
Monad m => CoSerial m Double Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Double -> b) Source #
Monad m => CoSerial m Float Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Float -> b) Source #
Monad m => CoSerial m Int Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Int -> b) Source #
Monad m => CoSerial m Word Source # | Since: 1.1.3
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Word -> b) Source #
CoSerial m a => CoSerial m (Complex a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Complex a -> b) Source #
CoSerial m a => CoSerial m (NonEmpty a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (NonEmpty a -> b) Source #
(Integral i, CoSerial m i) => CoSerial m (Ratio i) Source # | Since: 1.1
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Ratio i -> b) Source #
CoSerial m a => CoSerial m (Maybe a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Maybe a -> b) Source #
CoSerial m a => CoSerial m [a] Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m ([a] -> b) Source #
(CoSerial m a, CoSerial m b) => CoSerial m (Either a b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m (Either a b -> b0) Source #
(CoSerial m a, CoSerial m b) => CoSerial m (a, b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a, b) -> b0) Source #
(Serial m a, CoSerial m a, Serial m b, CoSerial m b) => CoSerial m (a -> b) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a -> b) -> b0) Source #
(CoSerial m a, CoSerial m b, CoSerial m c) => CoSerial m (a, b, c) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a, b, c) -> b0) Source #
(CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d) => CoSerial m (a, b, c, d) Source # |
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a, b, c, d) -> b0) Source #
(Monad m, CoSerial m (f (g a))) => CoSerial m (Compose f g a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b -> Series m (Compose f g a -> b) Source #
(CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e) => CoSerial m (a, b, c, d, e) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a, b, c, d, e) -> b0) Source #
(CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d, CoSerial m e, CoSerial m f) => CoSerial m (a, b, c, d, e, f) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods coseries :: Series m b0 -> Series m ((a, b, c, d, e, f) -> b0) Source #

# Generic implementations

genericSeries :: forall (m :: Type -> Type) a. (Monad m, Generic a, GSerial m (Rep a)) => Series m a Source #

Since: 1.1.5

genericCoseries :: forall (m :: Type -> Type) a b. (Monad m, Generic a, GCoSerial m (Rep a)) => Series m b -> Series m (a -> b) Source #

Since: 1.1.5

# Convenient wrappers

newtype Positive a Source #

`Positive` `x` guarantees that \( x > 0 \).

Since: 1.0

Constructors

Positive |

Fields

- getPositive :: a

#### Instances

Instances details

Functor Positive Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods fmap :: (a -> b) -> Positive a -> Positive b Source # (<$) :: a -> Positive b -> Positive a Source #
Foldable Positive Source # | Since: 1.2.0

Instance details

Defined in Test.SmallCheck.Series

Methods

fold :: Monoid m => Positive m -> m Source #

foldMap :: Monoid m => (a -> m) -> Positive a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Positive a -> m Source #

foldr :: (a -> b -> b) -> b -> Positive a -> b Source #

foldr' :: (a -> b -> b) -> b -> Positive a -> b Source #

foldl :: (b -> a -> b) -> b -> Positive a -> b Source #

foldl' :: (b -> a -> b) -> b -> Positive a -> b Source #

foldr1 :: (a -> a -> a) -> Positive a -> a Source #

foldl1 :: (a -> a -> a) -> Positive a -> a Source #

toList :: Positive a -> [a] Source #

null :: Positive a -> Bool Source #

length :: Positive a -> Int Source #

elem :: Eq a => a -> Positive a -> Bool Source #

maximum :: Ord a => Positive a -> a Source #

minimum :: Ord a => Positive a -> a Source #

sum :: Num a => Positive a -> a Source #

product :: Num a => Positive a -> a Source #

Traversable Positive Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods traverse :: Applicative f => (a -> f b) -> Positive a -> f (Positive b) Source # sequenceA :: Applicative f => Positive (f a) -> f (Positive a) Source # mapM :: Monad m => (a -> m b) -> Positive a -> m (Positive b) Source # sequence :: Monad m => Positive (m a) -> m (Positive a) Source #
(Num a, Ord a, Serial m a) => Serial m (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (Positive a) Source #
(Num a, Bounded a) => Bounded (Positive a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods minBound :: Positive a Source # maxBound :: Positive a Source #
Enum a => Enum (Positive a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

succ :: Positive a -> Positive a Source #

pred :: Positive a -> Positive a Source #

toEnum :: Int -> Positive a Source #

fromEnum :: Positive a -> Int Source #

enumFrom :: Positive a -> [Positive a] Source #

enumFromThen :: Positive a -> Positive a -> [Positive a] Source #

enumFromTo :: Positive a -> Positive a -> [Positive a] Source #

enumFromThenTo :: Positive a -> Positive a -> Positive a -> [Positive a] Source #

Num a => Num (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods (+) :: Positive a -> Positive a -> Positive a Source # (-) :: Positive a -> Positive a -> Positive a Source # (*) :: Positive a -> Positive a -> Positive a Source # negate :: Positive a -> Positive a Source # abs :: Positive a -> Positive a Source # signum :: Positive a -> Positive a Source # fromInteger :: Integer -> Positive a Source #
Integral a => Integral (Positive a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

quot :: Positive a -> Positive a -> Positive a Source #

rem :: Positive a -> Positive a -> Positive a Source #

div :: Positive a -> Positive a -> Positive a Source #

mod :: Positive a -> Positive a -> Positive a Source #

quotRem :: Positive a -> Positive a -> (Positive a, Positive a) Source #

divMod :: Positive a -> Positive a -> (Positive a, Positive a) Source #

toInteger :: Positive a -> Integer Source #

Real a => Real (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods toRational :: Positive a -> Rational Source #
Show a => Show (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods showsPrec :: Int -> Positive a -> ShowS Source # show :: Positive a -> String Source # showList :: [Positive a] -> ShowS Source #
Eq a => Eq (Positive a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods (==) :: Positive a -> Positive a -> Bool Source # (/=) :: Positive a -> Positive a -> Bool Source #
Ord a => Ord (Positive a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

compare :: Positive a -> Positive a -> Ordering Source #

(<) :: Positive a -> Positive a -> Bool Source #

(<=) :: Positive a -> Positive a -> Bool Source #

(>) :: Positive a -> Positive a -> Bool Source #

(>=) :: Positive a -> Positive a -> Bool Source #

max :: Positive a -> Positive a -> Positive a Source #

min :: Positive a -> Positive a -> Positive a Source #

newtype NonNegative a Source #

`NonNegative` `x` guarantees that \( x \ge 0 \).

Since: 1.0

Constructors

NonNegative |

Fields

- getNonNegative :: a

#### Instances

Instances details

Functor NonNegative Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods fmap :: (a -> b) -> NonNegative a -> NonNegative b Source # (<$) :: a -> NonNegative b -> NonNegative a Source #
Foldable NonNegative Source # | Since: 1.2.0

Instance details

Defined in Test.SmallCheck.Series

Methods

fold :: Monoid m => NonNegative m -> m Source #

foldMap :: Monoid m => (a -> m) -> NonNegative a -> m Source #

foldMap' :: Monoid m => (a -> m) -> NonNegative a -> m Source #

foldr :: (a -> b -> b) -> b -> NonNegative a -> b Source #

foldr' :: (a -> b -> b) -> b -> NonNegative a -> b Source #

foldl :: (b -> a -> b) -> b -> NonNegative a -> b Source #

foldl' :: (b -> a -> b) -> b -> NonNegative a -> b Source #

foldr1 :: (a -> a -> a) -> NonNegative a -> a Source #

foldl1 :: (a -> a -> a) -> NonNegative a -> a Source #

toList :: NonNegative a -> [a] Source #

null :: NonNegative a -> Bool Source #

length :: NonNegative a -> Int Source #

elem :: Eq a => a -> NonNegative a -> Bool Source #

maximum :: Ord a => NonNegative a -> a Source #

minimum :: Ord a => NonNegative a -> a Source #

sum :: Num a => NonNegative a -> a Source #

product :: Num a => NonNegative a -> a Source #

Traversable NonNegative Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods traverse :: Applicative f => (a -> f b) -> NonNegative a -> f (NonNegative b) Source # sequenceA :: Applicative f => NonNegative (f a) -> f (NonNegative a) Source # mapM :: Monad m => (a -> m b) -> NonNegative a -> m (NonNegative b) Source # sequence :: Monad m => NonNegative (m a) -> m (NonNegative a) Source #
(Num a, Ord a, Serial m a) => Serial m (NonNegative a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonNegative a) Source #
(Num a, Bounded a) => Bounded (NonNegative a) Source # | Since: 1.2.0
Instance details Defined in Test.SmallCheck.Series Methods minBound :: NonNegative a Source # maxBound :: NonNegative a Source #
Enum a => Enum (NonNegative a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

succ :: NonNegative a -> NonNegative a Source #

pred :: NonNegative a -> NonNegative a Source #

toEnum :: Int -> NonNegative a Source #

fromEnum :: NonNegative a -> Int Source #

enumFrom :: NonNegative a -> [NonNegative a] Source #

enumFromThen :: NonNegative a -> NonNegative a -> [NonNegative a] Source #

enumFromTo :: NonNegative a -> NonNegative a -> [NonNegative a] Source #

enumFromThenTo :: NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a] Source #

Num a => Num (NonNegative a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

(+) :: NonNegative a -> NonNegative a -> NonNegative a Source #

(-) :: NonNegative a -> NonNegative a -> NonNegative a Source #

(*) :: NonNegative a -> NonNegative a -> NonNegative a Source #

negate :: NonNegative a -> NonNegative a Source #

abs :: NonNegative a -> NonNegative a Source #

signum :: NonNegative a -> NonNegative a Source #

fromInteger :: Integer -> NonNegative a Source #

Integral a => Integral (NonNegative a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

quot :: NonNegative a -> NonNegative a -> NonNegative a Source #

rem :: NonNegative a -> NonNegative a -> NonNegative a Source #

div :: NonNegative a -> NonNegative a -> NonNegative a Source #

mod :: NonNegative a -> NonNegative a -> NonNegative a Source #

quotRem :: NonNegative a -> NonNegative a -> (NonNegative a, NonNegative a) Source #

divMod :: NonNegative a -> NonNegative a -> (NonNegative a, NonNegative a) Source #

toInteger :: NonNegative a -> Integer Source #

Real a => Real (NonNegative a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods toRational :: NonNegative a -> Rational Source #
Show a => Show (NonNegative a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods showsPrec :: Int -> NonNegative a -> ShowS Source # show :: NonNegative a -> String Source # showList :: [NonNegative a] -> ShowS Source #
Eq a => Eq (NonNegative a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods (==) :: NonNegative a -> NonNegative a -> Bool Source # (/=) :: NonNegative a -> NonNegative a -> Bool Source #
Ord a => Ord (NonNegative a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

compare :: NonNegative a -> NonNegative a -> Ordering Source #

(<) :: NonNegative a -> NonNegative a -> Bool Source #

(<=) :: NonNegative a -> NonNegative a -> Bool Source #

(>) :: NonNegative a -> NonNegative a -> Bool Source #

(>=) :: NonNegative a -> NonNegative a -> Bool Source #

max :: NonNegative a -> NonNegative a -> NonNegative a Source #

min :: NonNegative a -> NonNegative a -> NonNegative a Source #

newtype NonZero a Source #

`NonZero` `x` guarantees that \( x \ne 0 \).

Since: 1.2.0

Constructors

NonZero |

Fields

- getNonZero :: a

#### Instances

Instances details

Functor NonZero Source # |
Instance details Defined in Test.SmallCheck.Series Methods fmap :: (a -> b) -> NonZero a -> NonZero b Source # (<$) :: a -> NonZero b -> NonZero a Source #
Foldable NonZero Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

fold :: Monoid m => NonZero m -> m Source #

foldMap :: Monoid m => (a -> m) -> NonZero a -> m Source #

foldMap' :: Monoid m => (a -> m) -> NonZero a -> m Source #

foldr :: (a -> b -> b) -> b -> NonZero a -> b Source #

foldr' :: (a -> b -> b) -> b -> NonZero a -> b Source #

foldl :: (b -> a -> b) -> b -> NonZero a -> b Source #

foldl' :: (b -> a -> b) -> b -> NonZero a -> b Source #

foldr1 :: (a -> a -> a) -> NonZero a -> a Source #

foldl1 :: (a -> a -> a) -> NonZero a -> a Source #

toList :: NonZero a -> [a] Source #

null :: NonZero a -> Bool Source #

length :: NonZero a -> Int Source #

elem :: Eq a => a -> NonZero a -> Bool Source #

maximum :: Ord a => NonZero a -> a Source #

minimum :: Ord a => NonZero a -> a Source #

sum :: Num a => NonZero a -> a Source #

product :: Num a => NonZero a -> a Source #

Traversable NonZero Source # |
Instance details Defined in Test.SmallCheck.Series Methods traverse :: Applicative f => (a -> f b) -> NonZero a -> f (NonZero b) Source # sequenceA :: Applicative f => NonZero (f a) -> f (NonZero a) Source # mapM :: Monad m => (a -> m b) -> NonZero a -> m (NonZero b) Source # sequence :: Monad m => NonZero (m a) -> m (NonZero a) Source #
(Num a, Ord a, Serial m a) => Serial m (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonZero a) Source #
(Eq a, Num a, Bounded a) => Bounded (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods minBound :: NonZero a Source # maxBound :: NonZero a Source #
Enum a => Enum (NonZero a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

succ :: NonZero a -> NonZero a Source #

pred :: NonZero a -> NonZero a Source #

toEnum :: Int -> NonZero a Source #

fromEnum :: NonZero a -> Int Source #

enumFrom :: NonZero a -> [NonZero a] Source #

enumFromThen :: NonZero a -> NonZero a -> [NonZero a] Source #

enumFromTo :: NonZero a -> NonZero a -> [NonZero a] Source #

enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a] Source #

Num a => Num (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods (+) :: NonZero a -> NonZero a -> NonZero a Source # (-) :: NonZero a -> NonZero a -> NonZero a Source # (*) :: NonZero a -> NonZero a -> NonZero a Source # negate :: NonZero a -> NonZero a Source # abs :: NonZero a -> NonZero a Source # signum :: NonZero a -> NonZero a Source # fromInteger :: Integer -> NonZero a Source #
Integral a => Integral (NonZero a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

quot :: NonZero a -> NonZero a -> NonZero a Source #

rem :: NonZero a -> NonZero a -> NonZero a Source #

div :: NonZero a -> NonZero a -> NonZero a Source #

mod :: NonZero a -> NonZero a -> NonZero a Source #

quotRem :: NonZero a -> NonZero a -> (NonZero a, NonZero a) Source #

divMod :: NonZero a -> NonZero a -> (NonZero a, NonZero a) Source #

toInteger :: NonZero a -> Integer Source #

Real a => Real (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods toRational :: NonZero a -> Rational Source #
Show a => Show (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods showsPrec :: Int -> NonZero a -> ShowS Source # show :: NonZero a -> String Source # showList :: [NonZero a] -> ShowS Source #
Eq a => Eq (NonZero a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods (==) :: NonZero a -> NonZero a -> Bool Source # (/=) :: NonZero a -> NonZero a -> Bool Source #
Ord a => Ord (NonZero a) Source # |

Instance details

Defined in Test.SmallCheck.Series

Methods

compare :: NonZero a -> NonZero a -> Ordering Source #

(<) :: NonZero a -> NonZero a -> Bool Source #

(<=) :: NonZero a -> NonZero a -> Bool Source #

(>) :: NonZero a -> NonZero a -> Bool Source #

(>=) :: NonZero a -> NonZero a -> Bool Source #

max :: NonZero a -> NonZero a -> NonZero a Source #

min :: NonZero a -> NonZero a -> NonZero a Source #

newtype NonEmpty a Source #

`NonEmpty` `xs` guarantees that `xs` is not null.

Since: 1.1

Constructors

NonEmpty |

Fields

- getNonEmpty :: [a]

#### Instances

Instances details

Serial m a => Serial m (NonEmpty a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods series :: Series m (NonEmpty a) Source #
Show a => Show (NonEmpty a) Source # |
Instance details Defined in Test.SmallCheck.Series Methods showsPrec :: Int -> NonEmpty a -> ShowS Source # show :: NonEmpty a -> String Source # showList :: [NonEmpty a] -> ShowS Source #

# Other useful definitions

(\/) :: forall (m :: Type -> Type) a. Monad m => Series m a -> Series m a -> Series m a infixr 7 Source #

Sum (union) of series.

Since: 1.0

(><) :: forall (m :: Type -> Type) a b. Monad m => Series m a -> Series m b -> Series m (a, b) infixr 8 Source #

Product of series

Since: 1.0

(<~>) :: forall (m :: Type -> Type) a b. Monad m => Series m (a -> b) -> Series m a -> Series m b infixl 4 Source #

Fair version of `ap` and `<*>`.

Since: 1.0

(>>-) :: MonadLogic m => m a -> (a -> m b) -> m b infixl 1 Source #

Fair conjunction. Similarly to the previous function, consider the distributivity law, naturally expected from `MonadPlus`:

    (a <|> b) >>= k = (a >>= k) <|> (b >>= k)

If `a` `>>=` `k` can backtrack arbitrarily many times, `b` `>>=` `k` may never be considered. In logic statements, "backtracking" is the process of discarding the current possible solution value and returning to a previous decision point where a new value can be obtained and tried. For example:

    >>> do { x <- pure 0 <|> pure 1 <|> pure 2; if even x then pure x else empty } :: [Int]
    [0,2]

Here, the `x` value can be produced three times, where `<|>` represents the decision points of that production. The subsequent `if` statement specifies `empty` (fail) if `x` is odd, causing it to be discarded and a return to an `<|>` decision point to get the next `x`.

The statement "`a` `>>=` `k` can backtrack arbitrarily many times" means that the computation is resulting in `empty` and that `a` has an infinite number of `<|>` applications to return to. This is called a conjunctive computation because the logic for `a` and `k` must both succeed (i.e. `pure` a value instead of `empty`).

Similar to the way `interleave` allows both branches of a disjunctive computation, the `>>-` operator takes care to consider both branches of a conjunctive computation.

Consider the operation:

    odds = pure 1 <|> fmap (2 +) odds

    oddsPlus n = odds >>= \a -> pure (a + n)

    g = do x <- (pure 0 <|> pure 1) >>= oddsPlus
           if even x then pure x else empty

    >>> observeMany 3 g
    ...never completes...

This will never produce any value because all values produced by the `do` program come from the `pure` `1` driven operation (adding one to the sequence of odd values, resulting in the even values that are allowed by the test in the second line), but the `pure` `0` input to `oddsPlus` generates an infinite number of `empty` failures so the even values generated by the `pure` `1` alternative are never seen. Using `interleave` here instead of `<|>` does not help due to the aforementioned distributivity law.

Also note that the `do` notation desugars to `>>=` bind operations, so the following would also fail:

    do a <- pure 0 <|> pure 1
       x <- oddsPlus a
       if even x then pure x else empty

The solution is to use the `>>-` in place of the normal monadic bind operation `>>=` when fairness between alternative productions is needed in a conjunction of statements (rules):

    h = do x <- (pure 0 <|> pure 1) >>- oddsPlus
           if even x then pure x else empty

    >>> observeMany 3 h
    [2,4,6]

However, a bit of care is needed when using `>>-` because, unlike `>>=`, it is not associative. For example:

    >>> let m = [2,7] :: [Int]
    >>> let k x = [x, x + 1]
    >>> let h x = [x, x * 2]
    >>> m >>= (\x -> k x >>= h)
    [2,4,3,6,7,14,8,16]
    >>> (m >>= k) >>= h -- same as above
    [2,4,3,6,7,14,8,16]
    >>> m >>- (\x -> k x >>- h)
    [2,7,3,8,4,14,6,16]
    >>> (m >>- k) >>- h -- central elements are different
    [2,7,4,3,14,8,6,16]

This means that the following will be productive:

    (pure 0 <|> pure 1) >>-
      oddsPlus >>-
        \x -> if even x then pure x else empty

Which is equivalent to

    ((pure 0 <|> pure 1) >>- oddsPlus) >>-
      (\x -> if even x then pure x else empty)

But the following will not be productive:

    (pure 0 <|> pure 1) >>-
      (\a -> (oddsPlus a >>- \x -> if even x then pure x else empty))

Since do notation desugaring results in the latter, the `RebindableSyntax` or `QualifiedDo` language pragmas cannot easily be used either. Instead, it is recommended to carefully use explicit `>>-` only when needed.

Here is an action of `(>>-)` on lists:

    >>> take 20 $ [100,200..500] >>- (\x -> map (x +) [1..])
    [101,201,102,301,103,202,104,401,105,203,106,302,107,204,108,501,109,205,110,303]

The result is `map (100 +) [1..]` `interleave`d with `[200,300..500] >>- (x -> map (x +) [1..])`. You can see that a half of the numbers starts from 1, a quarter starts from 2, and so on exponentially. One could argue that `(>>-)` is a very unfair conjunction!

localDepth :: forall (m :: Type -> Type) a. (Depth -> Depth) -> Series m a -> Series m a Source #

Run a series with a modified depth.

Since: 1.0

decDepth :: forall (m :: Type -> Type) a. Series m a -> Series m a Source #

Run a `Series` with the depth decreased by 1.

If the current depth is less or equal to 0, the result is `empty`.

Since: 1.0

getDepth :: forall (m :: Type -> Type). Series m Depth Source #

Query the current depth.

Since: 1.0

generate :: forall a (m :: Type -> Type). (Depth -> [a]) -> Series m a Source #

A simple series specified by a function from depth to the list of values up to that depth.

Since: 1.0

limit :: forall (m :: Type -> Type) a. Monad m => Int -> Series m a -> Series m a Source #

Limit a `Series` to its first `n` elements.

Since: 1.1.5

listSeries :: Serial Identity a => Depth -> [a] Source #

Given a depth, return the list of values generated by a `Serial` instance.

For example, list all integers up to depth 1:

-     listSeries 1 :: [Int]   -- returns [0,1,-1]

Since: 1.1.2

list :: Depth -> Series Identity a -> [a] Source #

Return the list of values generated by a `Series`. Useful for debugging `Serial` instances.

Examples:

-     list 3 series :: [Int]                  -- returns [0,1,-1,2,-2,3,-3]

-     list 3 (series :: Series Identity Int)  -- returns [0,1,-1,2,-2,3,-3]

-     list 2 series :: [[Bool]]               -- returns [[],[True],[False]]

The first two are equivalent. The second has a more explicit type binding.

Since: 1.0

listM :: Applicative m => Depth -> Series m a -> m [a] Source #

Monadic version of `list`.

Since: 1.1

fixDepth :: forall (m :: Type -> Type) a. Series m a -> Series m (Series m a) Source #

Fix the depth of a series at the current level. The resulting series will no longer depend on the "ambient" depth.

Since: 1.1.1

decDepthChecked :: forall (m :: Type -> Type) a. Series m a -> Series m a -> Series m a Source #

If the current depth is 0, evaluate the first argument. Otherwise, evaluate the second argument with decremented depth.

Since: 1.1.1

constM :: Monad m => m b -> m (a -> b) Source #

    constM = liftM const

Since: 1.1.1

# Orphan instances

(Serial Identity a, Show a, Show b) => Show (a -> b) Source # |
Instance details Methods showsPrec :: Int -> (a -> b) -> ShowS Source # show :: (a -> b) -> String Source # showList :: [a -> b] -> ShowS Source #