From 5d4e86dff3218a861ede8ee5a83c4ac17bce0161 Mon Sep 17 00:00:00 2001 From: Niklas Gruhn Date: Sun, 28 Apr 2024 23:22:46 +0200 Subject: [PATCH] AffineExpr: set constraint operator precedence --- src/Theory/LinearArithmatic/Constraint.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Theory/LinearArithmatic/Constraint.hs b/src/Theory/LinearArithmatic/Constraint.hs index bd6682d..fea6c85 100644 --- a/src/Theory/LinearArithmatic/Constraint.hs +++ b/src/Theory/LinearArithmatic/Constraint.hs @@ -62,10 +62,20 @@ instance Num AffineExpr where negate (AffineExpr constant coeffs) = AffineExpr (negate constant) (M.map negate coeffs) +-- Same precedence as the usual comparison operators (==, <=, ...). +-- Otherwise arithmatic expressions have to be bracketed, +-- e.g. like this: `(x + y) .<= 3`. +infix 4 .== +infix 4 .<= +infix 4 .>= +infix 4 .> +infix 4 .< + -- | Construct `Equals` constraint. (.==) :: AffineExpr -> AffineExpr -> Constraint (.==) lhs_expr rhs_expr = (lhs_expr - rhs_expr, Equals) + -- | Construct `LessEquals` constraint. (.<=) :: AffineExpr -> AffineExpr -> Constraint (.<=) lhs_expr rhs_expr = (lhs_expr - rhs_expr, LessEquals)