@@ -9,13 +9,30 @@ module Type.Data.Ordering
9
9
, class Invert
10
10
, invert
11
11
, class Equals
12
+ , class Compare
13
+ , compare
14
+ , class IsLt
15
+ , isLt
16
+ , class IsEq
17
+ , isEq
18
+ , class IsGt
19
+ , isGt
20
+ , class IsLte
21
+ , isLte
22
+ , class IsGte
23
+ , isGte
12
24
, equals
13
25
) where
14
26
15
27
import Prim.Ordering (LT , EQ , GT , Ordering ) as PO
16
28
import Data.Ordering (Ordering (..))
17
29
import Type.Data.Boolean (True , False )
18
30
import Type.Proxy (Proxy (..))
31
+ import Data.Ordering (Ordering (..))
32
+ import Data.Symbol (SProxy )
33
+ import Prim.Ordering (Ordering , LT , EQ , GT )
34
+ import Prim.Symbol (class Compare ) as Symbol
35
+ import Type.Data.Boolean (class Or , BProxy (..), False , True , Boolean )
19
36
20
37
-- | Value proxy for `Ordering` types
21
38
-- | **Deprecated:** Use `Type.Proxy` instead
@@ -71,5 +88,40 @@ instance equalsLTGT :: Equals PO.LT PO.GT False
71
88
instance equalsGTLT :: Equals PO.GT PO.LT False
72
89
instance equalsGTEQ :: Equals PO.GT PO.EQ False
73
90
74
- equals :: forall proxy l r o . Equals l r o => proxy l -> proxy r -> Proxy o
75
- equals _ _ = Proxy
91
+ -- | Compares type a b
92
+ class Compare a b (o :: Ordering ) | a b -> o
93
+
94
+ compare :: forall a b o . Compare a b o => a -> b -> OProxy o
95
+ compare _ _ = OProxy
96
+
97
+ class IsLt a b (isLt :: Boolean ) | a b -> isLt
98
+ instance isLtTrue ∷ (Compare a b o , Equals o LT isLt ) => IsLt a b isLt
99
+
100
+ isLt :: forall a b isLt . IsLt a b isLt => a -> b -> BProxy isLt
101
+ isLt _ _ = BProxy
102
+
103
+ class IsGt a b (isGt :: Boolean ) | a b -> isGt
104
+ instance isGtCompare :: (Compare a b o , Equals o GT isGt ) => IsGt a b isGt
105
+
106
+ isGt :: forall a b isGt . IsGt a b isGt => a -> b -> BProxy isGt
107
+ isGt _ _ = BProxy
108
+
109
+ class IsEq a b (isEq :: Boolean ) | a b -> isEq
110
+ instance isEqCompare :: (Compare a b o , Equals o EQ isEq ) => IsEq a b isEq
111
+
112
+ isEq :: forall a b isEq . IsEq a b isEq => a -> b -> BProxy isEq
113
+ isEq _ _ = BProxy
114
+
115
+ class IsLte a b (isLte :: Boolean ) | a b -> isLte
116
+ instance isLteFromIs ∷ (IsEq a b isEq , IsLt a b isLt , Or isEq isLt isLte ) => IsLte a b isLte
117
+
118
+ isLte :: forall a b isLte . IsLte a b isLte => a -> b -> BProxy isLte
119
+ isLte _ _ = BProxy
120
+
121
+ class IsGte a b (isGte :: Boolean ) | a b -> isGte
122
+ instance isGteFromIs :: (IsEq a b isEq , IsGt a b isGt , Or isEq isGt isGte ) => IsGte a b isGte
123
+
124
+ isGte :: forall a b isGte . IsGte a b isGte => a -> b -> BProxy isGte
125
+ isGte _ _ = BProxy
126
+
127
+ instance compareOrd :: Symbol.Compare lhs rhs ord => Compare (SProxy lhs ) (SProxy rhs ) ord
0 commit comments