Module Fun.Generic

Generic functions.

module Meta : sig ... end

Generic function metadata keys.

val pp : 'a Type.Gist.t -> Stdlib.Format.formatter -> 'a -> unit

pp g ppf v formats v as described by g on ppf with a pseudo OCaml syntax similar to what you would see in the toplevel. The function can be selectively overriden via the Meta.Fmt metadata key. Fields whose Type.Gist.Meta.Ignore is true are not printed.

val equal : 'a Type.Gist.t -> 'a -> 'a -> bool

equal g v0 v1 determines the equality of values v0 and v1 as described by g. The process can be selectively overriden via the Meta.Equal metadata key. Fields whose Type.Gist.Meta.Ignore is true are ignored (are always equal).

The function raises Invalid_argument on functional values and abstract types without representation; you can ignore them by using Meta.Equal.ignore for their Meta.Equal key.

val compare : 'a Type.Gist.t -> 'a -> 'a -> int

compare g v0 v1 compares values v0 and v1 as described by g. The function can be selectively overriden via Meta.Compare metadata keys. Fields whose Type.Gist.Meta.Ignore is true are ignored (are always equal).

The function raises Invalid_argument on function values and abstract types without representation; you can ignore them by using Meta.Compare.ignore for their Meta.Compare key.

val random : 'a Type.Gist.t -> ?size:int -> ?state:Stdlib.Random.State.t -> unit -> 'a

random g ~state () generates a random value described by g. state is the random state to use, defaults to Random.get_state ().

FIXME do something with Type.Gist.Meta.Ignore.

size is an indicative strictly positive, size factor to let users control an upper bound on the size and complexity of generated values. It should be used by generators to proportionally bound the length of sequences or the number of nodes in trees. It can be altered by gists via the Meta.Random.Size key.

The function raises Invalid_argument on functional values (may be lifted in the future) and abstract types without representation; you can represent them by using a suitable Meta.Random.Gen.const constant value for the Meta.Random.Gen key.