1 {-# LANGUAGE NoImplicitPrelude #-}
2 {-# OPTIONS_GHC -fno-warn-tabs #-}
4 module Hcompta.Expr.Ord where
7 import Data.Ord (Ord(..))
9 import Hcompta.Expr.Bool
10 import Hcompta.Expr.Eq
11 import Hcompta.Expr.Dup
18 ) => Expr_Ord repr where
19 lt :: Ord a => repr a -> repr a -> repr Bool
21 le :: Ord a => repr a -> repr a -> repr Bool
22 le x y = (x `lt` y) `or` (x `eq` y)
24 ge :: Ord a => repr a -> repr a -> repr Bool
25 ge x y = neg (x `lt` y)
27 gt :: Ord a => repr a -> repr a -> repr Bool
28 gt x y = neg (x `le` y)
30 instance -- Expr_Ord Dup
33 ) => Expr_Ord (Dup r1 r2) where
34 lt (x1 `Dup` x2) (y1 `Dup` y2) = lt x1 y1 `Dup` lt x2 y2
35 le (x1 `Dup` x2) (y1 `Dup` y2) = le x1 y1 `Dup` le x2 y2
36 ge (x1 `Dup` x2) (y1 `Dup` y2) = ge x1 y1 `Dup` ge x2 y2
37 gt (x1 `Dup` x2) (y1 `Dup` y2) = gt x1 y1 `Dup` gt x2 y2