Thijs Alkemade avatar Thijs Alkemade committed af2dc42

Comparison for values with units.

Only works for Rationals. Eq Double is a joke.

Comments (0)

Files changed (2)

 
 cubic :: (Fractional f, Convertable c d, UnitMerge c c a, UnitMerge a c u) => Value f c d -> Value f u (Mul (Mul d d) d)
 cubic x = x .*. x .*. x
+
+wrapB :: (Convertable a b, Convertable c d, UnitEq c a True) => (Prelude.Rational -> Prelude.Rational -> Bool) -> Value Prelude.Rational a b -> Value Prelude.Rational c d -> Bool
+wrapB op a b = op (val a) (val $ coerceTo b a)
+
+(.==.), (.<.), (.>.), (.<=.), (.>=.) :: (Convertable a b, Convertable c d, UnitEq c a True) => Value Prelude.Rational a b -> Value Prelude.Rational c d -> Bool
+(.==.) = wrapB (Prelude.==)
+(.<.) = wrapB (Prelude.<)
+(.<=.) = wrapB (Prelude.<=)
+(.>.) = wrapB (Prelude.>)
+(.>=.) = wrapB (Prelude.>=)

src/UnitTyped/NoPrelude.hs

 asin, acos, atan :: (Floating f) => Value f CountUnit Count -> Value f CountUnit Radian
 asin = wrap2 Prelude.asin
 acos = wrap2 Prelude.acos
-atan = wrap2 Prelude.atan
+atan = wrap2 Prelude.atan
+
+infixl 5 ==, <, <=, >, >=
+
+(==), (<), (<=), (>), (>=) :: (Convertable a b, Convertable c d, UnitEq c a True) => Value Prelude.Rational a b -> Value Prelude.Rational c d -> Bool
+(==) = (.==.)
+(<) = (.<.)
+(<=) = (.<=.)
+(>) = (.>.)
+(>=) = (.>=.)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.