]> Git — Sourcephile - comptalang.git/blob - cli/Hcompta/Expr/Ord.hs
Adapte hcompta-cli.
[comptalang.git] / cli / Hcompta / Expr / Ord.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2 {-# OPTIONS_GHC -fno-warn-tabs #-}
3
4 module Hcompta.Expr.Ord where
5
6 import Data.Bool
7 import Data.Ord (Ord(..))
8
9 import Hcompta.Expr.Bool
10 import Hcompta.Expr.Eq
11 import Hcompta.Expr.Dup
12
13 -- * Class 'Expr_Ord'
14
15 class
16 ( Expr_Bool repr
17 , Expr_Eq repr
18 ) => Expr_Ord repr where
19 lt :: Ord a => repr a -> repr a -> repr Bool
20
21 le :: Ord a => repr a -> repr a -> repr Bool
22 le x y = (x `lt` y) `or` (x `eq` y)
23
24 ge :: Ord a => repr a -> repr a -> repr Bool
25 ge x y = neg (x `lt` y)
26
27 gt :: Ord a => repr a -> repr a -> repr Bool
28 gt x y = neg (x `le` y)
29
30 instance -- Expr_Ord Dup
31 ( Expr_Ord r1
32 , Expr_Ord r2
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