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.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulehedgehog-fn-1.0Haskell2010
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.
Tabulate the function
GArg U1Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalGArg V1Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg b => GArg (K1 a b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(GArg a, GArg b) => GArg (a :*: b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(GArg a, GArg b) => GArg (a :+: b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalGArg c => GArg (M1 a b c)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalReify a function whose domain has an instance of Generic
instance Arg A where allows functions which take As to be reified
Arg IntegerDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg VoidDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg Int16Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg Int32Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg Int64Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg Int8Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg BoolDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg IntDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg OrderingDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg ()Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg a => Arg (Maybe a)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalArg a => Arg [a]Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(Arg a, Arg b) => Arg (Either a b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(Arg a, Arg b) => Arg (a, b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalGVary U1Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalGVary V1Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary b => GVary (K1 a b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(GVary a, GVary b) => GVary (a :*: b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(GVary a, GVary b) => GVary (a :+: b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalGVary c => GVary (M1 a b c)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalBuild 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.
Vary IntegerDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary VoidDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary Int16Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary Int32Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary Int64Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary Int8Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary Word8Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary BoolDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary IntDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary OrderingDefined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary ()Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary a => Vary (Maybe a)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalVary a => Vary [a]Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(Vary a, Vary b) => Vary (Either a b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.Internal(Vary a, Vary b) => Vary (a, b)Defined in hedgehog-fn-1.0 · Hedgehog.Function.InternalBuild a co-generator for an Integral type
A CoGenT m a is used to perturb a GenT m b based on the value of the a. 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.
CoGenT m ~ Data.Functor.Contravariabe.Op (Endo (GenT m b))CoGenTapplyCoGenT :: forall b. a -> GenT m b -> GenT m bEvaluate a possibly partial function
Evaluate a total function. Unsafe.
Extract the root value from a TreeT. Unsafe.
Shrink the function
Evaluate an Fn
Generate a function using the user-supplied co-generator
Generate a function
Run the function generator to retrieve a function
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
Reify a function on Integrals