aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/macro/syntax/declaration.lux
blob: 511f10c30655fdf9ffb914f1cef5abe98be0f893 (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
(.require
 [library
  [lux (.except)
   [abstract
    [equivalence (.only Equivalence)]]
   [control
    ["<>" parser (.use "[1]#[0]" monad)]]
   [data
    ["[0]" product]
    ["[0]" text]
    [collection
     ["[0]" list (.use "[1]#[0]" functor)]]]
   [meta
    ["[0]" code (.only)
     ["<[1]>" \\parser (.only Parser)]]]]])

(type .public Declaration
  (Record
   [#name Text
    #arguments (List Text)]))

(def .public equivalence
  (Equivalence Declaration)
  (all product.equivalence
       text.equivalence
       (list.equivalence text.equivalence)
       ))

(def .public parser
  (Parser Declaration)
  (<>.either (<>.and <code>.local
                     (<>#in (list)))
             (<code>.form (<>.and <code>.local
                                  (<>.some <code>.local)))))

(def .public (format value)
  (-> Declaration Code)
  (let [g!name (code.local (the #name value))]
    (when (the #arguments value)
      {.#End}
      g!name
      
      arguments
      (` ((, g!name) (,* (list#each code.local arguments)))))))