(.module: lux (lux function) (// [equivalence #+ Equivalence])) ## [Signatures] (signature: #export (Order a) {#.doc "A signature for types that possess some sense of ordering among their elements."} (: (Equivalence a) eq) (do-template [] [(: (-> a a Bool) )] [<] [<=] [>] [>=] ) ) ## [Values] (def: #export (order eq <) (All [a] (-> (Equivalence a) (-> a a Bool) (Order a))) (let [> (flip <)] (struct (def: eq eq) (def: < <) (def: (<= test subject) (or (< test subject) (:: eq = test subject))) (def: > >) (def: (>= test subject) (or (> test subject) (:: eq = test subject)))))) (do-template [ ] [(def: #export ( order x y) (All [a] (-> (Order a) a a a)) (if (:: order y x) x y))] [max >] [min <] )