aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/macro/syntax/declaration.lux
blob: ae6ae3ee7a105fb6fac6ab1807875934168f4c6f (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
(.module:
  [library
   [lux #*
    [abstract
     [equivalence (#+ Equivalence)]]
    [control
     ["<>" parser ("#\." monad)
      ["<.>" code (#+ Parser)]]]
    [data
     ["." product]
     ["." text]
     [collection
      ["." list ("#\." functor)]]]
    [macro
     ["." code]]]])

(type: .public Declaration
  (Record
   {#name Text
    #arguments (List Text)}))

(def: .public equivalence
  (Equivalence Declaration)
  ($_ product.equivalence
      text.equivalence
      (list.equivalence text.equivalence)
      ))

(def: .public parser
  (Parser Declaration)
  (<>.either (<>.and <code>.local_identifier
                     (<>\in (list)))
             (<code>.form (<>.and <code>.local_identifier
                                  (<>.some <code>.local_identifier)))))

(def: .public (format value)
  (-> Declaration Code)
  (let [g!name (code.local_identifier (value@ #name value))]
    (case (value@ #arguments value)
      #.End
      g!name
      
      arguments
      (` ((~ g!name) (~+ (list\each code.local_identifier arguments)))))))