package coq
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=3cbfc1e1a72b16d4744f5b64ede59586071e31d9c11c811a0372060727bfd9c3
doc/coq-core.library/Goptions/index.html
Module Goptions
Source
This module manages customization parameters at the vernacular level
Two kinds of things are managed : tables and options value
- Tables are created by applying the
MakeTable
functor. - Variables storing options value are created by applying one of the
declare_int_option
,declare_bool_option
, ... functions.
Each table/option is uniquely identified by a key of type option_name
which consists in a list of strings. Note that for parsing constraints, table names must not be made of more than 2 strings while option names can be of arbitrary length.
The declaration of a table, say of name ["Toto";"Titi"]
automatically makes available the following vernacular commands:
Add Toto Titi foo. Remove Toto Titi foo. Print Toto Titi. Test Toto Titi.
The declaration of a non boolean option value, say of name ["Tata";"Tutu";"Titi"]
, automatically makes available the following vernacular commands:
Set Tata Tutu Titi val. Print Table Tata Tutu Titi.
If it is the declaration of a boolean value, the following vernacular commands are made available:
Set Tata Tutu Titi. Unset Tata Tutu Titi. Print Table Tata Tutu Titi. (** synonym: Test Table Tata Tutu Titi. *)
All options are synchronized with the document.
Tables.
The functor MakeStringTable
declares a table containing objects of type string
; the function member_message
say what to print when invoking the "Test Toto Titi foo." command; at the end title
is the table name printed when invoking the "Print Toto Titi." command; active
is roughly the internal version of the vernacular "Test ...": it tells if a given object is in the table; elements
returns the list of elements of the table
The functor MakeRefTable
declares a new table of objects of type A.t
practically denoted by reference
; the encoding function encode : env -> reference -> A.t
is typically a globalization function, possibly with some restriction checks; the function member_message
say what to print when invoking the "Test Toto Titi foo." command; at the end title
is the table name printed when invoking the "Print Toto Titi." command; active
is roughly the internal version of the vernacular "Test ...": it tells if a given object is in the table.
Options.
These types and function are for declaring a new option of name key
and access functions read
and write
; the parameter name
is the option name used when printing the option value (command "Print Toto Titi."
The declare_*_option functions are low-level, to be used when implementing complex option workflows, e.g. when setting one option changes the value of another. For most use cases, you should use the helper functions declare_*_option_and_ref.
type 'a option_sig = {
optdepr : bool;
(*whether the option is DEPRECATED
*)optkey : option_name;
(*the low-level name of this option
*)optread : unit -> 'a;
optwrite : 'a -> unit;
}
The preprocess
function is triggered before setting the option. It can be used to emit a warning on certain values, and clean-up the final value.
declare_stringopt_option
should be preferred to declare_string_option
because it supports "Unset". Only "Warnings" option is declared using the latter.
val declare_int_option :
?preprocess:(int option -> int option) ->
int option option_sig ->
unit
val declare_stringopt_option :
?preprocess:(string option -> string option) ->
string option option_sig ->
unit
Helpers to declare a reference controlled by an option. Read-only as to avoid races.
Special functions supposed to be used only in vernacentries.ml
type 'a table_of_A = {
add : Environ.env -> 'a -> unit;
remove : Environ.env -> 'a -> unit;
mem : Environ.env -> 'a -> unit;
print : unit -> unit;
}
The first argument is a locality flag.
val set_string_option_append_value_gen :
?locality:option_locality ->
option_name ->
string ->
unit
val set_option_value :
?locality:option_locality ->
('a -> option_value -> option_value) ->
option_name ->
'a ->
unit
set_option_value ?locality f name v
sets name
to the result of applying f
to v
and name
's current value. Use for behaviour depending on the type of the option, eg erroring when 'a
doesn't match it. Changing the type will result in errors later so don't do that.
Summary of an option status