aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/meta/macro/template.lux
blob: b28454262ab238a27d6f725a76e8b6491c3857f2 (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
(.require
 [library
  [lux (.except let symbol)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list]]]]]
 [\\library
  ["[0]" /]])

(.def .public documentation
  (.List $.Module)
  ($.module /._
            "Utilities commonly used while templating."
            [($.default /.irregular_arguments)

             ($.definition /.spliced
               ""
               [(spliced [a b c d])
                "=>"
                a
                b
                c
                d])

             ($.definition /.amount
               ""
               [(amount [a b c d])
                "=>"
                4])

             ($.definition /.with_locals
               "Creates names for local bindings aliased by the names you choose."
               [(with_locals [my_var]
                  (let [my_var 123]
                    (text [my_var])))
                "=>"
                "__gensym__my_var506"])

             ($.definition /.text
               "A text literal made by concatenating pieces of code."
               [(text [#0 123 +456 +789.0 "abc" .def ..ghi])
                "=>"
                "#0123+456+789.0abcdefghi"])

             ($.definition /.symbol
               (format "An symbol made by concatenating pieces of code."
                       \n "The (optional) module part and the short part are specified independently.")
               [(symbol ["abc" .def ..ghi])
                "=>"
                abcdefghi]
               [(symbol [.def] ["abc" .def ..ghi])
                "=>"
                .abcdefghi])

             ($.definition /.let
               "Lexically-bound templates."
               [(let [(!square <root>)
                      [(* <root> <root>)]]
                  (def (square root)
                    (-> Nat Nat)
                    (!square root)))])]
            []))