module Generic_core_desc_fun:sig
..end
The module Generic_core_desc
defines the datatype
desc
which is a low level generic view giving a detailed
description of types. The present module defines the
extensible function Generic_core_desc_fun.view
that associates the
description to each type. To extend desc
to cover new
types, the function Generic_core_desc_fun.ext
is used.
All the types reflected in Generic_core_ty
are
given a desc
definition in this module.
type
desc_fun = {
|
f : |
desc_fun
takes a type witness 'a ty
and
computes the description 'a desc
val view : 'a Ty.ty -> 'a Desc.t
Type_pattern_match_failure
if the type doesn't
have a view yet. You can use Generic_core_desc_fun.ext
to extend view
to cover those cases.val ext : 'a Ty.pat -> desc_fun -> unit
ext pattern new_case
extends desc
with a new_case
corresponding to the types that match pattern
.Type_pattern_overwrite
when trying to extend desc
with a case that is already covered.Generic_core_desc_fun.ext_register
, then add its constructors
one by one using Generic_core_desc_fun.ext_add_con
. The functions ext_{conap,iter,fold}
all act on extensible variants
and raise Invalid_argument
in case the type isn't extensible.val ext_register : 'a Ty.ty -> string -> unit
Pattern_overwrite
the type already has a desc view.val ext_add_con : 'a Ty.ty -> Desc.Ext.con -> unit
val ext_conap : 'a Ty.ty -> 'a -> 'a Desc.Con.conap
Type_pattern_match_failure
if the type isn't registered yet.Invalid_argument
if the type is not an extensible type.Not_found
if the constructor hasn't been added previously.val ext_iter : 'a Ty.ty -> ('a Desc.Con.t -> unit) -> unit
ext_iter t f
executes f
on each constructor registered with the extensible variant witnessed by t
.Type_pattern_match_failure
if the type isn't registered yet.Invalid_argument
if the type is not an extensible type.val ext_fold : 'a Ty.ty -> ('a Desc.Con.t -> 'b -> 'b) -> 'b -> 'b
ext_fold t
is similar to List.fold_right
executed on the list of constructors of the extensible variant witnessed by t
.Type_pattern_match_failure
if the type isn't registered yet.Invalid_argument
if the type is not an extensible type.