... 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)))))))