aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/abstract/equivalence.lux
blob: 81b3b7d2f3d3369ee9e90c2a145951278e8ae364 (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
... 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)]]
 [//
  [functor
   ["[0]" contravariant]]])

(type .public (Equivalence a)
  (Interface
   (is (-> a a Bit)
       =)))

(def .public (rec sub)
  (All (_ a)
    (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a)))
  (implementation
   (def (= left right)
     (sub = left right))))

(def .public functor
  (contravariant.Functor Equivalence)
  (implementation
   (def (each f equivalence)
     (implementation
      (def (= reference sample)
        (of equivalence = (f reference) (f sample)))))))