Module Genr_base


module Genr_base: sig .. end

Basic definitions for generation functions.




type generated_function =
| Construction of Parsetree.generator * Code.pattern list * Code.exp
| Comparison of Code.lident * Code.pattern list * Code.exp
| Construction_helper of Code.lident * Code.pattern list * Code.exp
| Construction_record of Code.lident * Code.pattern list * Code.exp
type generated_functions = generated_function list 
val is_construction_function : generated_function -> bool
type binary_fun_exp = Code.exp -> Code.exp -> Code.exp 
The type of a function that takes two expression arguments and returns an expression that represents the application of the function to these arguments.
type comparisons = binary_fun_exp * binary_fun_exp *
binary_fun_exp
The triple of a lesser, an equal, and a greater predicate.
val comparison_function : Longident.t option -> Code.exp
A constant representing the name of the comparison function corresponding to the indicated identifier. Returns the standard comparison function if no identifier is provided.

Comparison expressions.

val genr_comparisons : Code.lident option -> comparisons
Generation of a triple of comparison functions for a given commutative operator.
val pervasives_comparisons : comparisons
Triple representing OCaml's Pervasives.compare functions
val eq_function : binary_fun_exp -> Code.exp -> Code.exp -> Code.exp
Returns the function that generates the code to call the proper equality function to its two code arguments. The proper equality function is "eq" or the binary_fun_exp argument, according to whether we have or have not to generate maximally shared terms for the relational type at hand.
val get_user_rel_order : unit -> bool
Do we use the user order for code generation ?
val set_user_rel_order : unit -> unit
val order_rels : (Parsetree.relation -> int) ->
Parsetree.relation list -> Parsetree.relation list
val order_relations : (Parsetree.relation -> int) -> Parsetree.relations -> Parsetree.relations
val set_sharable_target : unit -> unit
Maximum sharing handling.

val get_sharable_target : unit -> bool
Do we generate maximum sharing ?

Handling function names and identifiers.

val compare_function : Parsetree.generator -> Code.lident
Comparison function ident from its generator
val construction_function_name : string -> string
Construction function name from its generator (string) name.
val construction_function_ident : Code.uident -> Code.lident
Construction function ident from its generator ident.
val construction_function : Parsetree.generator -> Code.lident
Construction function ident from its generator.
val construction_function_memo_table_ident : Parsetree.generator -> Code.lident
Construction function memo table ident from its generator.
val prefix_ident : string -> Code.lident -> Code.lident
Adds a prefix to an identifier. prefix_ident p id is the identifier p_id is id is not qualified, Mod.p_id if id is qualified by module Mod.
val prefix_construction_function : string -> Parsetree.generator -> Code.lident
Name of the generation functions for a given prefix name and a given generator: prefix_generator_function p g is the ident "prefix_name", where "prefix" is the contents of p, and "name" is the uncapitalized version of g.
val prefix_construction_function2 : string -> Parsetree.generator -> Parsetree.generator -> Code.lident
Name of the generation functions for a given prefix name and the combination of two generators: prefix_generator_function2 p g1 g2 is the ident "prefix_name1_name2", where "prefix" is the contents of p, and "name1", "name2" are the uncapitalized versions of g1, g2.
val mk_sharing_function_ident : Parsetree.generator -> Code.lident
Name of the sharing generation functions for a given generator name.

Applying construction functions of generators.

val construction : Parsetree.generator -> Code.exp list -> Code.exp
The generic (and most general) way to apply a construction function for a generator. construction properly takes care of the generator arity, whatever this arity could be.

The following specialized versions are just particular case of the generic construction function.

val construction0 : Parsetree.generator -> Code.exp
val construction1 : Parsetree.generator -> Code.exp -> Code.exp
val construction2 : Parsetree.generator -> Code.exp -> Code.exp -> Code.exp
The application of the construction function for a zeroary, unary or binary generator.

Applying generators.


We use the generators as unconstrainted term builders.

Presumably, the following functions are only used once to define the construction function of a generator: we need it to build the (last) default clause of the construction function (unless we have a proof that a direct call to the generator is safe, because we know that the resulting term will be in normal form).

val generator : Parsetree.generator -> Code.exp list -> Code.exp
Apply the generator term constructor for the generator: in case of sharing, we properly call the sharing version of the generator.
val generator0 : Parsetree.generator -> Code.exp
val generator1 : Parsetree.generator -> Code.exp -> Code.exp
val generator2 : Parsetree.generator -> Code.exp -> Code.exp -> Code.exp
Apply the generator term constructor for the generator: special cases for zeroary, unary, and binary generators.

Generation of usual list operations.

val nil : Code.exp
These functions generate code values.
val singleton : Code.exp -> Code.exp
val cons : Code.exp -> Code.exp -> Code.exp
val append : Code.exp -> Code.exp -> Code.exp
val genr_rule_pattern : Parsetree.pattern -> Parsetree.pattern
Pattern construction for generators and functions.

Generation of the LHS of a pattern matching clause for a user's defined rule.

val pattern_info : Parsetree.generator -> Code.pattern -> Code.pattern list -> Code.pattern
Similar to generator application for the pattern case.
val pattern : Parsetree.generator -> Code.pattern list -> Code.pattern
val pattern0 : Parsetree.generator -> Code.pattern
val pattern1 : Parsetree.generator -> Code.pattern -> Code.pattern
val pattern2 : Parsetree.generator -> Code.pattern -> Code.pattern -> Code.pattern
Similar to generator application for the pattern case.

Generation of functions for relational types.

val genr_eq : string * Parsetree.type_declaration -> Code.structure_item
Generate an equality predicate primitive for the type name given: for type t, we generate the primitive eq_t, bound to "%equal" if the values of the type are not maximally shared, or bound to "%eq" otherwise.
val genr_projection : string * Parsetree.type_declaration ->
Parsetree.core_type -> Code.structure_item
Generate a projection primitive for the (abbreviation) type name given.

Functions to select a clause according to the side argument.

val clauses_of_side : Parsetree.relation_side ->
Code.clause -> Code.clause -> Code.clauses -> Code.clauses
val clauses_left_or_right : Parsetree.relation_side ->
Code.clause -> Code.clause -> Code.clauses -> Code.clauses
val clauses_both_as_left : Parsetree.relation_side ->
Code.clause -> Code.clause -> Code.clauses -> Code.clauses
val opt : bool -> Code.clause -> Code.clauses -> Code.clauses
Functions to generate clauses on demand.

val lazy_opt : bool -> (unit -> Code.clause) -> Code.clauses -> Code.clauses
val opts : bool -> Code.clauses -> Code.clauses -> Code.clauses

Mapping according to the distributivity.

val map_of_direction : Parsetree.distributivity_direction -> ('a -> 'b) -> 'a list -> 'b list
Returns the map like function from the predefined List module that is suitable for the distributivity_direction argument. This function is used to generate the code.
val imap_of_direction : Parsetree.distributivity_direction -> Longident.t
Returns the qualified identificateur of the mapping function of the predefined List module that is suitable for the distributivity_direction argument. This identifier will be used in the generated code.

Tracing normalization for generated code

val diese_line : Location.t -> int * string
Get the line and file where the located element appears
val set_dline_trace : unit -> unit
val get_dline_trace : unit -> bool
Do we add diese line directives to .ml files ?
val set_comments : unit -> unit
val get_comments : unit -> bool
Do we output normalization traces ?
val trace_clause : int -> string -> Code.clause -> Code.clause
Returns the code outputing the diese_line directives # int string