From 6a08602f5100417f9fc6c9838934a7974567a36b Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Mon, 30 Sep 2024 15:04:16 +0200 Subject: [PATCH] Add and export relop related utils Signed-off-by: Mathieu Barbin --- master_changes.md | 2 ++ src/format/opamFormula.ml | 2 ++ src/format/opamFormula.mli | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/master_changes.md b/master_changes.md index 4a4a5094825..219e7180689 100644 --- a/master_changes.md +++ b/master_changes.md @@ -145,6 +145,8 @@ users) ## opam-solver ## opam-format + * `OpamFormula.string_of_relop`: export function [#6197 @mbarbin] + * `OpamFormula.all_relop`: a list of all operators [#6197 @mbarbin] ## opam-core * `OpamStd.Sys.{get_terminal_columns,uname,getconf,guess_shell_compat}`: Harden the process calls to account for failures [#6230 @kit-ty-kate - fix #6215] diff --git a/src/format/opamFormula.ml b/src/format/opamFormula.ml index 96e651175e7..1acff0411fc 100644 --- a/src/format/opamFormula.ml +++ b/src/format/opamFormula.ml @@ -11,6 +11,8 @@ type relop = [`Eq|`Neq|`Geq|`Gt|`Leq|`Lt] +let all_relop = [ `Eq ; `Neq ; `Geq ; `Gt ; `Leq ; `Lt ] + let neg_relop = function | `Eq -> `Neq | `Neq -> `Eq diff --git a/src/format/opamFormula.mli b/src/format/opamFormula.mli index ea27df83bd2..99a4c1d74c3 100644 --- a/src/format/opamFormula.mli +++ b/src/format/opamFormula.mli @@ -17,6 +17,13 @@ type relop = OpamParserTypes.FullPos.relop_kind (* = [ `Eq | `Neq | `Geq | `Gt | val compare_relop : relop -> relop -> int +(** A list containing each available operator once. *) +val all_relop : relop list + +(** Returns a string representing the operator in infix syntax, as + used in opam files (">", "=", etc.) *) +val string_of_relop : relop -> string + (** Version constraints for OPAM *) type version_constraint = relop * OpamPackage.Version.t