aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/package.lux
blob: 841a0e5816ffce0d0ebd1c587e34b6221fb18bd1 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(.using
  [library
   [lux {"-" local}
    [abstract
     [equivalence {"+" Equivalence}]]
    [control
     ["[0]" try {"+" Try} ("[1]#[0]" functor)]
     [parser
      ["<[0]>" xml]]]
    [data
     ["[0]" sum]
     ["[0]" product]
     ["[0]" binary {"+" Binary}]
     [text
      [encoding
       ["[0]" utf8]]]
     [format
      ["[0]" xml {"+" XML}]]
     [collection
      [set {"+" Set}]]]]]
  ["[0]" // "_"
   ["/" profile]
   ["[1][0]" hash]
   ["[1][0]" pom]
   [dependency {"+" Dependency}
    ["[1][0]" status {"+" Status}]]
   [repository
    [remote {"+" Address}]
    ["[1][0]" origin {"+" Origin}]]])

(type: .public Package
  (Record
   [#origin Origin
    #library [Binary Status]
    #pom [XML Binary Status]]))

(template [<name> <tag>]
  [(def: .public (<name> package)
     (-> Package Bit)
     (case (value@ #origin package)
       {<tag> _}
       true
       
       _
       false))]

  [local? //origin.#Local]
  [remote? //origin.#Remote]
  )

(def: .public (local pom library)
  (-> XML Binary Package)
  [#origin {//origin.#Local ""}
   #library [library
             {//status.#Verified (//hash.sha-1 library)
                                 (//hash.md5 library)}]
   #pom (let [binary_pom (|> pom (# xml.codec encoded) (# utf8.codec encoded))]
          [pom
           binary_pom
           {//status.#Verified (//hash.sha-1 binary_pom)
                               (//hash.md5 binary_pom)}])])

(def: .public dependencies
  (-> Package (Try (Set Dependency)))
  (|>> (value@ #pom)
       product.left
       list
       (<xml>.result //pom.parser)
       (try#each (value@ /.#dependencies))))

(def: .public repositories
  (-> Package (Try (Set Address)))
  (|>> (value@ #pom)
       product.left
       list
       (<xml>.result //pom.parser)
       (try#each (value@ /.#repositories))))

(def: .public equivalence
  (Equivalence Package)
  ($_ product.equivalence
      //origin.equivalence
      ($_ product.equivalence
          binary.equivalence
          //status.equivalence)
      ($_ product.equivalence
          xml.equivalence
          binary.equivalence
          //status.equivalence)
      ))