aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/dependency/status.lux
blob: bab454ea6a7cdb66e9b2b5af0662a8bbe9b3cf67 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
(.using
  [library
   [lux "*"
    [abstract
     [equivalence {"+" Equivalence}]]
    [data
     [binary {"+" Binary}]
     ["[0]" sum]
     ["[0]" product]]]]
  ["[0]" /// "_"
   ["[1][0]" hash {"+" Hash SHA-1 MD5}]])

(type: .public Status
  (Variant
   {#Unverified}
   {#Partial (Either (Hash SHA-1)
                     (Hash MD5))}
   {#Verified (Hash SHA-1) (Hash MD5)}))

(implementation: any_equivalence
  (Equivalence Any)

  (def: (= _ _)
    true))

(def: .public equivalence
  (Equivalence Status)
  ($_ sum.equivalence
      ..any_equivalence
      ($_ sum.equivalence
          ///hash.equivalence
          ///hash.equivalence)
      ($_ product.equivalence
          ///hash.equivalence
          ///hash.equivalence)
      ))

(def: .public (verified payload)
  (-> Binary Status)
  {#Verified
   (///hash.sha-1 payload)
   (///hash.md5 payload)})