aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux
blob: bc35ee361be8b76f3bdcb22a8bfbe40c7b7075dd (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
(.using
 [library
  [lux (.except Module)
   [abstract
    [equivalence (.only Equivalence)]]
   [control
    ["<>" parser (.only)
     ["<[0]>" binary (.only Parser)]]]
   [data
    ["[0]" product]
    ["[0]" text]
    [collection
     ["[0]" set (.only Set)]]
    ["[0]" format
     ["[1]" binary (.only Writer)]]]
   [macro
    ["^" pattern]]
   [math
    [number
     ["[0]" nat]]]
   [world
    [file (.only Path)]]]])

(type: .public Module
  Text)

(def: .public runtime
  Module
  "")

(type: .public Descriptor
  (Record
   [#name Module
    #file Path
    #hash Nat
    #state Module_State
    #references (Set Module)]))

(implementation: module_state_equivalence
  (Equivalence Module_State)
  
  (def: (= left right)
    (case [left right]
      (^.with_template [<tag>]
        [[{<tag>} {<tag>}]
         true])
      ([.#Active]
       [.#Compiled]
       [.#Cached])

      _
      false)))

(def: .public equivalence
  (Equivalence Descriptor)
  (all product.equivalence
       text.equivalence
       text.equivalence
       nat.equivalence
       ..module_state_equivalence
       set.equivalence
       ))

(def: .public writer
  (Writer Descriptor)
  (all format.and
       format.text
       format.text
       format.nat
       format.any
       (format.set format.text)
       ))

(def: .public parser
  (Parser Descriptor)
  (all <>.and
       <binary>.text
       <binary>.text
       <binary>.nat
       (at <>.monad in {.#Cached})
       (<binary>.set text.hash <binary>.text)
       ))