blob: 40f3a2ccbf7d1b89ebbe6f21fc96765b90325128 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
(.require
[library
[lux (.except)
[control
["[0]" function]]]]
[//
["[0]" equivalence (.only Equivalence)]
[functor
["[0]" contravariant]]])
(type .public (Order a)
(Interface
(is (Equivalence a)
equivalence)
(is (-> a a Bit)
<)))
(type .public (Comparison a)
(-> (Order a) a a Bit))
(def .public (<= order parameter subject)
Comparison
(or (of order < parameter subject)
(of order = parameter subject)))
(def .public (> order parameter subject)
Comparison
(of order < subject parameter))
(def .public (>= order parameter subject)
Comparison
(or (of order < subject parameter)
(of order = subject parameter)))
(type .public (Choice a)
(-> (Order a) a a a))
(def .public (min order x y)
Choice
(if (of order < y x) x y))
(def .public (max order x y)
Choice
(if (of order < y x) y x))
(def .public functor
(contravariant.Functor Order)
(implementation
(def (each f order)
(implementation
(def equivalence
(of equivalence.functor each f (of order equivalence)))
(def (< reference sample)
(of order < (f reference) (f sample)))))))
|