aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/abstract/hash.lux
blob: ef5df60226b1e2f3364240eb29c90e12e4a10945 (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
(.using
 [library
  [lux (.except)]]
 [//
  ["[0]" equivalence (.only Equivalence)]
  [functor
   ["[0]" contravariant]]])

(type: .public (Hash a)
  (Interface
   (is (Equivalence a)
       equivalence)
   (is (-> a Nat)
       hash)))

(def .public functor
  (contravariant.Functor Hash)
  (implementation
   (def (each f super)
     (implementation
      (def equivalence
        (at equivalence.functor each f
            (at super equivalence)))
      
      (def hash
        (|>> f (at super hash)))))))