| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hedgehog.Function.Internal
Synopsis
- data a :-> c where
- table :: (a :-> c) -> [(a, c)]
- class GArg a where
- gbuild :: (Generic a, GArg (Rep a)) => (a -> c) -> a :-> c
- class Arg a where
- variant :: Word64 -> GenT m b -> GenT m b
- variant' :: Word64 -> CoGenT m b -> CoGenT m b
- class GVary a where
- gvary :: (Generic a, GVary (Rep a)) => CoGenT m a
- class Vary a where
- varyIntegral :: Integral a => CoGenT m a
- newtype CoGenT m a = CoGenT {
- applyCoGenT :: forall b. a -> GenT m b -> GenT m b
- type CoGen = CoGenT Identity
- apply' :: (a :-> b) -> a -> Maybe b
- unsafeApply :: (a :-> b) -> a -> b
- data Fn a b = Fn b (a :-> TreeT (MaybeT Identity) b)
- unsafeFromTree :: Functor m => TreeT (MaybeT m) a -> m a
- shrinkFn :: (b -> [b]) -> (a :-> b) -> [a :-> b]
- shrinkTree :: Monad m => TreeT (MaybeT m) a -> m [TreeT (MaybeT m) a]
- apply :: Fn a b -> a -> b
- fnWith :: Arg a => CoGen a -> Gen b -> Gen (Fn a b)
- fn :: (Arg a, Vary a) => Gen b -> Gen (Fn a b)
- forAllFn :: (Show a, Show b, Monad m) => Gen (Fn a b) -> PropertyT m (a -> b)
- via :: Arg b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
- gvia :: GArg b => (a -> b x) -> (b x -> a) -> (a -> c) -> a :-> c
- buildIntegral :: (Arg a, Integral a) => (a -> c) -> a :-> c
Documentation
data a :-> c where infixr 5 Source #
Shrinkable, showable functions
Claessen, K. (2012, September). Shrinking and showing functions:(functional pearl). In ACM SIGPLAN Notices (Vol. 47, No. 12, pp. 73-80). ACM.
Constructors
| Unit :: c -> () :-> c | |
| Nil :: a :-> c | |
| Pair :: (a :-> (b :-> c)) -> (a, b) :-> c | |
| Sum :: (a :-> c) -> (b :-> c) -> Either a b :-> c | |
| Map :: (a -> b) -> (b -> a) -> (b :-> c) -> a :-> c |
gbuild :: (Generic a, GArg (Rep a)) => (a -> c) -> a :-> c Source #
Reify a function whose domain has an instance of Generic
instance Arg A where allows functions which take As to be reified
Minimal complete definition
Nothing
Methods
build :: (a -> c) -> a :-> c Source #
build :: (Generic a, GArg (Rep a)) => (a -> c) -> a :-> c Source #
Instances
| Arg Bool Source # | |
| Arg Int Source # | |
| Arg Int8 Source # | |
| Arg Int16 Source # | |
| Arg Int32 Source # | |
| Arg Int64 Source # | |
| Arg Integer Source # | |
| Arg Ordering Source # | |
| Arg () Source # | |
Defined in Hedgehog.Function.Internal | |
| Arg Void Source # | |
| Arg a => Arg [a] Source # | |
Defined in Hedgehog.Function.Internal | |
| Arg a => Arg (Maybe a) Source # | |
| (Arg a, Arg b) => Arg (Either a b) Source # | |
| (Arg a, Arg b) => Arg (a, b) Source # | |
Defined in Hedgehog.Function.Internal | |
gvary :: (Generic a, GVary (Rep a)) => CoGenT m a Source #
Build a co-generator for a type which has a Generic instance
Vary provides a canonical co-generator for a type.
While technically there are many possible co-generators for a given type, we don't get any benefit from caring.
Minimal complete definition
Nothing
Instances
| Vary Bool Source # | |
| Vary Int Source # | |
| Vary Int8 Source # | |
| Vary Int16 Source # | |
| Vary Int32 Source # | |
| Vary Int64 Source # | |
| Vary Integer Source # | |
| Vary Ordering Source # | |
| Vary Word8 Source # | |
| Vary () Source # | |
Defined in Hedgehog.Function.Internal | |
| Vary Void Source # | |
| Vary a => Vary [a] Source # | |
Defined in Hedgehog.Function.Internal | |
| Vary a => Vary (Maybe a) Source # | |
| (Vary a, Vary b) => Vary (Either a b) Source # | |
| (Vary a, Vary b) => Vary (a, b) Source # | |
Defined in Hedgehog.Function.Internal | |
A is used to perturb a CoGenT m a based on the value of the GenT m ba. This way,
the generated function will have a varying (but still deterministic) right hand side.
Co-generators can be built using Divisible and Decidable, but it is recommended to
derive Generic and use the default instance of the Vary type class.
CoGenTm ~Op(Endo(GenTm b))
Constructors
| CoGenT | |
Fields
| |
unsafeApply :: (a :-> b) -> a -> b Source #
Evaluate a total function. Unsafe.
The type of randomly-generated functions
unsafeFromTree :: Functor m => TreeT (MaybeT m) a -> m a Source #
Extract the root value from a TreeT. Unsafe.
fnWith :: Arg a => CoGen a -> Gen b -> Gen (Fn a b) Source #
Generate a function using the user-supplied co-generator
forAllFn :: (Show a, Show b, Monad m) => Gen (Fn a b) -> PropertyT m (a -> b) Source #
Run the function generator to retrieve a function
via :: Arg b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c Source #
Reify a function via an isomorphism.
If your function's domain has no instance of Generic then you can still reify it using
an isomorphism to a better domain type. For example, the Arg instance for Integral
uses an isomorphism from Integral a => a to (Bool, [Bool]), where the first element
is the sign, and the second element is the bit-string.
Note: via f g will only be well-behaved if g . f = id and f . g = id