Module OpamFormula
Formulas on packages, opt. with sub-formulas on versions, and conversion functions
type relop= OpamParserTypes.relopbinary operations (compatible with the Dose type for Cudf operators!)
type version_constraint= relop * OpamPackage.Version.tVersion constraints for OPAM
type atom= OpamPackage.Name.t * version_constraint optionFormula atoms for OPAM
val string_of_atom : atom -> stringPretty-printing of atoms
val short_string_of_atom : atom -> stringThe compact atom format used in requests, "pkgOPvers", with '.' allowed instead of '='
val string_of_atoms : atom list -> stringPrints atoms as a conjunction ("&") using the short format
val check : atom -> OpamPackage.t -> boolChecks if a package verifies an atom
val packages_of_atoms : OpamPackage.Set.t -> atom list -> OpamPackage.Set.tReturn all packages satisfying the given atoms from a set (i.e. name matching at least one of the atoms, version matching all atoms with the appropriate name)
val string_of_conjunction : ('a -> string) -> 'a conjunction -> stringPretty print AND formulas
val string_of_disjunction : ('a -> string) -> 'a disjunction -> stringPretty print OR formulas
type 'a cnf= 'a disjunction conjunctionCNF formulas (Conjunctive Normal Form)
type 'a dnf= 'a conjunction disjunctionDNF formulas (Disjunctive Normal Form)
val string_of_cnf : ('a -> string) -> 'a cnf -> stringPretty print CNF formulas
val string_of_dnf : ('a -> string) -> 'a dnf -> stringPretty print DNF formulas
type 'a formula=|Empty|Atom of 'a|Block of 'a formula|And of 'a formula * 'a formula|Or of 'a formula * 'a formulaGeneral formulas
val eval : ('a -> bool) -> 'a formula -> boolEval a formula
val partial_eval : ('a -> [ `Formula of 'b formula | `True | `False ]) -> 'a formula -> [ `Formula of 'b formula | `True | `False ]val check_relop : relop -> int -> boolCheck a relational operator against an integer from compare
val eval_relop : relop -> OpamPackage.Version.t -> OpamPackage.Version.t -> boolEvaluate a relational operator between versions
val neg_relop : relop -> relopval string_of_formula : ('a -> string) -> 'a formula -> stringPretty print a formula
val ands : 'a formula list -> 'a formulaConvert a list of formulas to an AND-formula (
Emptyformulas are ignored)
val ands_to_list : 'a formula -> 'a formula listConverts back an AND-formula to a list (flattens top-level ands)
val ors : 'a formula list -> 'a formulaConvert a list of formulas to an OR-formula (
Emptyformulas are ignored)
val ors_to_list : 'a formula -> 'a formula listConverts back an OR-formula to a list (flattens top-level ors)
val map : ('a -> 'b formula) -> 'a formula -> 'b formulaMap on atoms. Atoms for which the given function returns Empty will be simply removed
val map_up_formula : ('a formula -> 'a formula) -> 'a formula -> 'a formulaMaps bottom-up on a formula (atoms first)
val neg : ('a -> 'a) -> 'a formula -> 'a formulaNegates a formula (given the function to negate atoms)
val iter : ('a -> unit) -> 'a formula -> unitIter function
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b formula -> 'aFold function (bottom-up, left-to-right)
val fold_right : ('a -> 'b -> 'a) -> 'a -> 'b formula -> 'aFold function (bottom-up, right-to-left)
type version_formula= version_constraint formulaExpressions composed entirely of version constraints
val check_version_formula : version_formula -> OpamPackage.Version.t -> boolChecks if a given version satisfies a formula
type t= (OpamPackage.Name.t * version_formula) formulaAn atom is:
name* (relop*version) formula. Examples of valid formulae:- "foo" {> "1" & (<"3" | ="5")}
- "foo" {= "1" | > "4"} | ("bar" "bouh")
val verifies : t -> OpamPackage.t -> boolReturns
trueifpackageverifiesformula(i.e. it is within at least one package set that is a solution of the formula, and is named in the formula)
val packages : OpamPackage.Set.t -> t -> OpamPackage.Set.tReturns the subset of packages possibly matching the formula (i.e. including all disjunction cases)
val to_atom_formula : t -> atom formulaTransform a formula where versions can be expressed using formulas to a flat atom formula
val simplify_ineq_formula : ('a -> 'a -> int) -> (relop * 'a) formula -> (relop * 'a) formula optionsimplify_ineq_formula comp freturns a canonical version of inequality formulaf, based on comparison functioncomp, where each version appears at most once, and in increasing order. ReturnsSome Emptyif the formula is alwaystrue,Noneif it is always false
val simplify_version_formula : version_formula -> version_formula optionLike
simplify_ineq_formula, but specialised on version formulas
val simplify_version_set : OpamPackage.Version.Set.t -> version_formula -> version_formulaA more aggressive version of
simplify_version_formulathat attempts to find a shorter formula describing the same subset of versions within a given set. The empty formula is returned for an empty set, and the original formula is otherwise returned as is if no versions match.
val formula_of_version_set : OpamPackage.Version.Set.t -> OpamPackage.Version.Set.t -> version_formulaformula_of_version_set set subsetgenerates a formula that is enough to describe all packages ofsubsetand exclude packages otherwise inset
Atoms
val to_string : t -> stringPretty print the formula
val to_conjunction : t -> atom conjunctionReturn a conjunction. If the initial formula is not a conjunction, then fail.
val of_conjunction : atom conjunction -> tReturn a formula from a conjunction of atoms
val to_disjunction : t -> atom disjunctionReturn a disjunction of atoms from a package formula. It the initial formula is not a disjunction, then fail.
val set_to_disjunction : OpamPackage.Set.t -> t -> atom disjunctionLike
to_disjunction, but accepts conjunctions within constraint formulas, resolving them using the provided package set. Conjunctions between packages still raiseFailure.
val of_disjunction : atom disjunction -> tReturn a formula from a disjunction of atoms