aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler.lux
blob: 0bac9c1bea3f93ea535db1d07428bf167c13fddc (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
(.require
 [library
  [lux (.except Module Code #module)
   [control
    ["<>" parser (.only)]
    ["[0]" try (.only Try)]
    ["[0]" exception (.only Exception)]]
   [data
    ["[0]" text]
    ["[0]" binary (.only Binary)
     [\\format (.only Format)]
     ["<[1]>" \\parser (.only Parser)]]]
   [world
    ["[0]" file (.only Path)]]]]
 [/
  [meta
   ["[0]" archive (.only Output Archive)
    [key (.only Key)]
    [module
     [descriptor (.only Descriptor Module)]
     [document (.only Document)]]]]])

(type .public Code
  Text)

(type .public Parameter
  Text)

(type .public Input
  (Record
   [#module Module
    #file Path
    #hash Nat
    #code Code]))

(type .public (Compilation s d)
  (Record
   [#dependencies (List Module)
    #process (-> s Archive
                 (Try [s (Either (Compilation s d)
                                 (archive.Entry d))]))]))

(type .public (Compiler s d)
  (-> Input (Compilation s d)))

(type .public Custom
  (Ex (_ state document)
    [state
     (Key document)
     (Format document)
     (Parser document)
     (-> Input (Try (Compilation state document)))]))

(type .public (Instancer s d)
  (-> (Key d) (List Parameter) (Compiler s d)))

(exception.def .public (cannot_compile module)
  (Exception Module)
  (exception.report
   (list ["Module" module])))