Idris2Doc : Hedgehog.Internal.Function

Hedgehog.Internal.Function

(source)

Definitions

interfaceCogen : Type->Type
  An interface for co-generators, somewhat an inverse of a generator

Generators, roughly, using a random seed produce a value of a certain type.
Co-generators conversly, roughtly speaking, produce a random seed using
a value of a certain type.

Due to technical properties of a seed type, instead of generating a seed
value from stratch we perturb some existing value.
Thus, a function of this interface produces a `StdGen -> StdGen` function
being given a value of an appropriate type.

In some understanding, co-generators classify values of a given type, which
allow to tune generators of other types.
This gives an ability to generate functions of type `a -> b` being given
a generator of type `b` and a co-generator of type `a`.
Having a value of type `a`, co-generator can deterministically tune
the generator of type `b` by perturbing a random seed that is used by the
generator and use its output as an output for a function.

Parameters: a
Constructor: 
MkCogen

Methods:
perturb : a->StdGen->StdGen

Implementations:
Cogen ()
Cogen (x=y)
CogenBool
CogenNat
CogenInteger
CogenBits64
CogenBits16
CogenBits8
CogenInt64
CogenInt16
CogenInt8
CogenInt
CogenChar
CogenVoid
Cogena=>Cogenb=>Cogen (a, b)
Cogena=>Cogenb=>Cogen (Eitherab)
Cogena=>Cogen (Maybea)
Cogena=>Cogen (Lista)
CogenString
perturb : Cogena=>a->StdGen->StdGen
Totality: total
Visibility: public export
shiftArg : StdGen->StdGen
  This function perturbs the given seed both with `variant` and `split`.

This function is meant to be used between successive perturbations
of different arguments of the same constructor.

It is designed to not commute when perturbation actions of a constructor's
arguments do the same.
Consider if `Cogen` interface is implemented for `Maybe a` and `Bool`
in the following way:

```
Cogen a => Cogen (Maybe a) where
perturb (Just x) = perturb x . variant 0
perturb Nothing = variant 1

Cogen Bool where
perturb False = variant 0
perturb True = variant 1
```

In this case values `Nothing` and `Just True` would give the same
perturbation to a seed, which is not optimal. Insertion of `shiftArg`
before each call for `perturb` of a constructor argument would give
different perturbations for different combinations of constructors and
their arguments (unless you are very unlucky).
Combination of both `variant` and `split` in the `shiftArg` function
gives relative independence on how `perturb` of a constructor argument
type is implemented.

Totality: total
Visibility: export
cogen : Cogena=>a->Genb->Genb
  Changes random distribution of a generator of type `b`
based on a value of type `a`

Change of distribution is done by a perturbation of a random seed,
which is based on a `Cogen` implementation for the type `a`.

Totality: total
Visibility: export
function_ : Cogena=>Genb->Gen (a->b)
  Generates a random function being given a generator of codomain type

This function takes a co-generator of domain type using `auto`-argument
based on the type.
This generator does not shrink.

Notice that this generator returns a non-showable value (unless you invent
your own implementation).
If you need a showable function, you have to use a shrinkable version,
which requires more strict implementation on the domain type.

Totality: total
Visibility: export
depfun_ : Cogena=> {0b : a->Type} -> ((x : a) ->Gen (bx)) ->Gen ((x : a) ->bx)
  Generates a random dependently typed function being given a generator
of codomain type family

This function takes a co-generator of domain type using `auto`-argument
based on the type.
This generator does not shrink.

Notice that this generator returns a non-showable value (unless you invent
your own implementation).

Totality: total
Visibility: export
dargfun_ : {0b : a->Type} ->Cogen (bx) =>Genc->Gen (bx->c)
  Generates a random function with dependently typed domain being given a
generator of codomain type

This function takes a co-generator of domain type family using
`auto`-argument based on the type.
This generator does not shrink.

Notice that this generator returns a non-showable value (unless you invent
your own implementation).

Totality: total
Visibility: export
dargdepfun_ : {0b : a->Type} -> {0c : bx->Type} ->Cogen (bx) => ((y : bx) ->Gen (cy)) ->Gen ((y : bx) ->cy)
  Generates a random dependently typed function with dependently typed domain
being given a generator of codomain type family

This function takes a co-generator of domain type family using
`auto`-argument based on the type.
This generator does not shrink.

Notice that this generator returns a non-showable value (unless you invent
your own implementation).

Totality: total
Visibility: export
data(:->) : Type->Type->Type
  A type of reified partial functions that can be represented isomorphic
to a function defined by pattern matching of an ADT
or any type that *can* implement `Generic` (but does not have to).

This type describes internal structure of such functions,
e.g. storing separately "vertical" and "horizontal" matching,
thus allowing to inspect, modify and simplify them,
for example, for showing and shrinking.

Totality: total
Visibility: public export
Constructors:
FUnit : c-> () :->c
FNil : a:->c
FPair : Lazy (a:-> (b:->c)) -> (a, b) :->c
FSum : Lazy (a:->c) -> Lazy (b:->c) ->Eitherab:->c
FMap : (a->b) -> (b->a) -> Lazy (b:->c) ->a:->c

Hint: 
Functor ((a:->))

Fixity Declaration: infixr operator, level 5
interfaceShrCogen : Type->Type
Parameters: a
Constraints: Cogen a
Constructor: 
MkShrCogen

Methods:
build : (a->c) ->a:->c

Implementations:
ShrCogenVoid
ShrCogen ()
ShrCogena=>ShrCogenb=>ShrCogen (a, b)
ShrCogena=>ShrCogenb=>ShrCogen (Eitherab)
ShrCogena=>ShrCogen (Maybea)
ShrCogenBool
ShrCogena=>ShrCogen (Lista)
ShrCogen (x=x)
ShrCogenInteger
ShrCogenNat
ShrCogenInt
ShrCogenInt8
ShrCogenInt16
ShrCogenInt64
ShrCogenBits8
ShrCogenBits16
ShrCogenBits64
ShrCogenChar
ShrCogenString
build : ShrCogena=> (a->c) ->a:->c
Totality: total
Visibility: public export
via : ShrCogenb=> (a->b) -> (b->a) -> (a->c) ->a:->c
  Implements `build` function for a type through isomorphism
to a type that implements `ShrCogen`

Notice that `via f g` will only be well-behaved if
`g . f` and `f . g` are both identity functions.

Totality: total
Visibility: export
dataFn : Type->Type->Type
  The type for a total randomly-generated function

Totality: total
Visibility: export
Constructor: 
MkFn : b->a:->Cotreeb->Fnab

Hint: 
Showa=>Showb=>Show (Fnab)
function : ShrCogena=>Genb->Gen (Fnab)
  Generates a random function being given a generator of codomain type

The generated function is returned in a showable type `Fn a b`.

This function takes a co-generator of domain type using `auto`-argument
based on the type.
This generator is shrinkable. For this, it requires additional `Arg`
argument.

Totality: total
Visibility: export
apply : Fnab->a->b
  Coverts a showable randomly generated function to an actual function

Totality: total
Visibility: export
function' : ShrCogena=>Genb->Gen (a->b)
  Generates a random function being given a generator of codomain type

This generator is shrinkable

This is a wrapper of a `function` generator.
It may be useful sometimes, however, it returnes a non-showable type.
To use functions generator in `forAll` in a property, use `function`
generator.

Totality: total
Visibility: public export