3 | import Prelude.Basics
14 | interface Eq ty where
17 | (==) : ty -> ty -> Bool
19 | (/=) : ty -> ty -> Bool
21 | x == y = not (x /= y)
22 | x /= y = not (x == y)
35 | False == False = True
40 | x == y = intToBool (prim__eq_Int x y)
44 | x == y = intToBool (prim__eq_Integer x y)
48 | x == y = intToBool (prim__eq_Bits8 x y)
52 | x == y = intToBool (prim__eq_Bits16 x y)
56 | x == y = intToBool (prim__eq_Bits32 x y)
60 | x == y = intToBool (prim__eq_Bits64 x y)
64 | x == y = intToBool (prim__eq_Int8 x y)
68 | x == y = intToBool (prim__eq_Int16 x y)
72 | x == y = intToBool (prim__eq_Int32 x y)
76 | x == y = intToBool (prim__eq_Int64 x y)
80 | x == y = intToBool (prim__eq_Double x y)
84 | x == y = intToBool (prim__eq_Char x y)
88 | x == y = intToBool (prim__eq_String x y)
91 | Eq a => Eq b => Eq (a, b) where
92 | (x1, y1) == (x2, y2) = x1 == x2 && y1 == y2
95 | data Ordering = LT | EQ | GT
98 | contra : Ordering -> Ordering
113 | interface Eq ty => Ord ty where
116 | compare : ty -> ty -> Ordering
117 | compare x y = if x < y then LT else if x == y then EQ else GT
120 | (<) : ty -> ty -> Bool
121 | (<) x y = compare x y == LT
124 | (>) : ty -> ty -> Bool
125 | (>) x y = compare x y == GT
128 | (<=) : ty -> ty -> Bool
129 | (<=) x y = compare x y /= GT
132 | (>=) : ty -> ty -> Bool
133 | (>=) x y = compare x y /= LT
136 | max : ty -> ty -> ty
137 | max x y = if x > y then x else y
140 | min : ty -> ty -> ty
141 | min x y = if (x < y) then x else y
144 | comparing : Ord a => (b -> a) -> b -> b -> Ordering
145 | comparing p x y = compare (p x) (p y)
148 | [Reverse] (fwd : Ord a) => Ord a where
149 | compare x y = contra $
compare @{fwd} x y
153 | compare _ _ impossible
161 | compare False False = EQ
162 | compare False True = LT
163 | compare True False = GT
164 | compare True True = EQ
168 | (<) x y = intToBool (prim__lt_Int x y)
169 | (<=) x y = intToBool (prim__lte_Int x y)
170 | (>) x y = intToBool (prim__gt_Int x y)
171 | (>=) x y = intToBool (prim__gte_Int x y)
175 | (<) x y = intToBool (prim__lt_Integer x y)
176 | (<=) x y = intToBool (prim__lte_Integer x y)
177 | (>) x y = intToBool (prim__gt_Integer x y)
178 | (>=) x y = intToBool (prim__gte_Integer x y)
182 | compareInteger : (x, y : Integer) -> Ordering
183 | compareInteger = compare
187 | (<) x y = intToBool (prim__lt_Bits8 x y)
188 | (<=) x y = intToBool (prim__lte_Bits8 x y)
189 | (>) x y = intToBool (prim__gt_Bits8 x y)
190 | (>=) x y = intToBool (prim__gte_Bits8 x y)
194 | (<) x y = intToBool (prim__lt_Bits16 x y)
195 | (<=) x y = intToBool (prim__lte_Bits16 x y)
196 | (>) x y = intToBool (prim__gt_Bits16 x y)
197 | (>=) x y = intToBool (prim__gte_Bits16 x y)
201 | (<) x y = intToBool (prim__lt_Bits32 x y)
202 | (<=) x y = intToBool (prim__lte_Bits32 x y)
203 | (>) x y = intToBool (prim__gt_Bits32 x y)
204 | (>=) x y = intToBool (prim__gte_Bits32 x y)
208 | (<) x y = intToBool (prim__lt_Bits64 x y)
209 | (<=) x y = intToBool (prim__lte_Bits64 x y)
210 | (>) x y = intToBool (prim__gt_Bits64 x y)
211 | (>=) x y = intToBool (prim__gte_Bits64 x y)
215 | (<) x y = intToBool (prim__lt_Int8 x y)
216 | (<=) x y = intToBool (prim__lte_Int8 x y)
217 | (>) x y = intToBool (prim__gt_Int8 x y)
218 | (>=) x y = intToBool (prim__gte_Int8 x y)
222 | (<) x y = intToBool (prim__lt_Int16 x y)
223 | (<=) x y = intToBool (prim__lte_Int16 x y)
224 | (>) x y = intToBool (prim__gt_Int16 x y)
225 | (>=) x y = intToBool (prim__gte_Int16 x y)
229 | (<) x y = intToBool (prim__lt_Int32 x y)
230 | (<=) x y = intToBool (prim__lte_Int32 x y)
231 | (>) x y = intToBool (prim__gt_Int32 x y)
232 | (>=) x y = intToBool (prim__gte_Int32 x y)
236 | (<) x y = intToBool (prim__lt_Int64 x y)
237 | (<=) x y = intToBool (prim__lte_Int64 x y)
238 | (>) x y = intToBool (prim__gt_Int64 x y)
239 | (>=) x y = intToBool (prim__gte_Int64 x y)
243 | (<) x y = intToBool (prim__lt_Double x y)
244 | (<=) x y = intToBool (prim__lte_Double x y)
245 | (>) x y = intToBool (prim__gt_Double x y)
246 | (>=) x y = intToBool (prim__gte_Double x y)
250 | (<) x y = intToBool (prim__lt_String x y)
251 | (<=) x y = intToBool (prim__lte_String x y)
252 | (>) x y = intToBool (prim__gt_String x y)
253 | (>=) x y = intToBool (prim__gte_String x y)
257 | (<) x y = intToBool (prim__lt_Char x y)
258 | (<=) x y = intToBool (prim__lte_Char x y)
259 | (>) x y = intToBool (prim__gt_Char x y)
260 | (>=) x y = intToBool (prim__gte_Char x y)
263 | Ord a => Ord b => Ord (a, b) where
264 | compare (x1, y1) (x2, y2)
265 | = if x1 /= x2 then compare x1 x2