aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/package.lux
blob: 03f2c3994c6c5f53843fe69beb8c066154d16b69 (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
(.module:
  [lux #*
   [abstract
    [equivalence (#+ Equivalence)]]
   [control
    ["." try (#+ Try) ("#\." functor)]
    [parser
     ["<.>" xml]]]
   [data
    ["." sum]
    ["." product]
    ["." binary (#+ Binary)]
    [format
     ["." xml (#+ XML)]]
    [collection
     [set (#+ Set)]]]]
  ["." // #_
   [dependency (#+ Dependency)
    ["#." status (#+ Status)]]
   ["/" profile]
   ["#." hash (#+ Hash SHA-1 MD5)]
   ["#." pom]])

(type: #export Origin
  #Local
  #Remote)

(structure: any-equivalence
  (Equivalence Any)

  (def: (= _ _)
    true))

(def: origin-equivalence
  (Equivalence Origin)
  ($_ sum.equivalence
      ..any-equivalence
      ..any-equivalence
      ))

(type: #export Package
  {#origin Origin
   #library [Binary Status]
   #pom [XML Status]})

(template [<name> <tag>]
  [(def: #export <name>
     (-> Package Bit)
     (|>> (get@ #origin) (\ ..origin-equivalence = <tag>)))]

  [local? #Local]
  [remote? #Remote]
  )

(def: #export (local pom library)
  (-> XML Binary Package)
  {#origin #Local
   #library [library #//status.Unverified]
   #pom [pom #//status.Unverified]})

(def: #export dependencies
  (-> Package (Try (Set Dependency)))
  (|>> (get@ #pom)
       product.left
       (<xml>.run //pom.parser)
       (try\map (get@ #/.dependencies))))

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