aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/dependency/status.lux
blob: fec0d1301442c1013e1a41b80bc955b352135dcd (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
43
44
45
... 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)
   [abstract
    [equivalence (.only Equivalence)]]
   [data
    [binary (.only Binary)]
    ["[0]" sum]
    ["[0]" product]]]]
 ["[0]" ///
  ["[1][0]" hash (.only Hash SHA1 MD5)]])

(type .public Status
  (Variant
   {#Unverified}
   {#Partial (Either (Hash SHA1)
                     (Hash MD5))}
   {#Verified (Hash SHA1) (Hash MD5)}))

(def any_equivalence
  (Equivalence Any)
  (implementation
   (def (= _ _)
     true)))

(def .public equivalence
  (Equivalence Status)
  (all sum.equivalence
       ..any_equivalence
       (all sum.equivalence
            ///hash.equivalence
            ///hash.equivalence)
       (all product.equivalence
            ///hash.equivalence
            ///hash.equivalence)
       ))

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