aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux
blob: b3fc0fb098e7ddba0dec5c41e6c756ef58e36527 (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
(.require
 [library
  [lux (.except Module)
   [abstract
    [equivalence (.only Equivalence)]]
   [control
    ["<>" parser]]
   [data
    ["[0]" product]
    ["[0]" text]
    ["[0]" binary
     ["[0]" \\format (.only Writer)]
     ["<[1]>" \\parser (.only Parser)]]
    [collection
     ["[0]" set (.only Set)]]]
   [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)]))

(def module_state_equivalence
  (Equivalence Module_State)
  (implementation
   (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)
       ))