package regenerate

  1. Overview
  2. Docs

Module Regenerate.MakeSource

Regenerate.Make(W)(S)(A) is a module that implements sample generation for words implemented by the module W with the alphabet A. S describes the data structure used internally for the enumeration of words.

For casual use of the library, consider using arbitrary instead.

Parameters

module Word : Word.S
module Segment : Segments.S with type elt = Word.t
module Sigma : SIGMA with type t = Segment.t

Signature

Sourcetype node =
  1. | Nothing
  2. | Everything
  3. | Cons of Segment.t * lang
Sourceand lang = unit -> node

A language is a lazy stream of words segmented by growing length.

Sourceval pp : Format.formatter -> lang -> unit

pp fmt lang pretty print the language lang.

gen regex returns the language recognized by regex.

Sampling

Sourcetype res =
  1. | Done
  2. | Finite
  3. | GaveUp
Sourceexception ExitSample
Sourceval sample : ?st:Random.State.t -> ?n:int -> ?firsts:int -> skip:int -> lang -> (Segment.elt -> unit) -> res

sample ~skip ~n lang returns a sequence of on average n elements. lang is only consumed when needed.

We sample one element every k, where k follows a power law of average skip. Furthermore, if we consume more than sqrt k empty segments, we assume that the rest of the segments will be infinitely empty and stop.

If firsts is provided, we always output the firsts first elements.

Operations on languages

Sourceval flatten : lang -> Segment.elt Iter.t

flatten lang returns the sequence of its segments.

Regular operations

Sourceval union : lang -> lang -> lang
Sourceval inter : lang -> lang -> lang
Sourceval difference : lang -> lang -> lang
Sourceval compl : lang -> lang
Sourceval concatenate : lang -> lang -> lang
Sourceval star : (unit -> node) -> unit -> node
Sourceval rep : int -> int option -> lang -> lang
Sourceval charset : bool -> Word.char list -> unit -> node
OCaml

Innovation. Community. Security.