aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/abstract/hash.lux
blob: de0599a23b917c4be4e5a3cbead92f4e28d803ea (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
(.module:
  [library
   [lux "*"]]
  [//
   ["[0]" equivalence {"+" Equivalence}]
   [functor
    ["[0]" contravariant]]])

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

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