Legend:
Library
Module
Module type
Parameter
Class
Class type
Formulas on variables, as used in opam files build scripts
Filters are a small language of formulas over strings and booleans used for conditions and text replacements. It has relational operators over strings (using version-number comparison), And, Or and Not boolean operations, dynamic casting (using strings "true" and "false"), and string interpolation. Variables are resolved using a user function returning an option, undefined values are propagated.
String interpolation uses the syntax %{identifier}%
Identifiers have the form
[package:]var[?str_if_true:str_if_false_or_undef]v}.
The last optional part specifies a conversion from boolean to static strings.
The syntax [pkg1+pkg2+pkgn:var] is allowed as a shortcut to
[pkg1:var & pkg2:var & pkgn:var].
The special variable [pkg:enable] is allowed as a shortcut for
[pkg:installed?enable:disable]
The type of filter idents with (optionally multiple) qualifying package names and optional string converter. Package name None encodes the self-reference _
Maps on all variables appearing in a filter. The case where package variables are renamed differently and appear in a filter ident of the form %{pkg1+pkg2:var}% is not supported and raises Invalid_argument.
val expand_string :
?partial:bool ->?default:(string -> string)->env->string ->
string
Rewrites string interpolations within a string. default is applied to the fident string (e.g. what's between %{ and }%) when the expansion is undefined. If unspecified, this raises Failure.
With partial, default defaults to the identity, and is otherwise expected to return a fident. In this case, the returned string is supposed to be expanded again (expansion results are escaped, escapes are otherwise kept). This makes the function idempotent
val unclosed_expansions : string ->((int * int) * string) list
Returns the (beginning, end) offsets and substrings of any unclosed %{ expansions
Same as eval_to_bool, but takes an option as filter and returns always true on None, false when the filter is Undefined. This is the most common behaviour for using "filters" for filtering
default indicates the result to assume when a filter is undefined; this is normally false when computing the universe. Will raise as other filter functions if undefined and default is not given.
Resolves the build, test, doc, dev flags in a filtered formula (which is supposed to have been pre-processed to remove switch and global variables). default determines the behaviour on undefined filters, raising if undefined