aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/document.lux
blob: 9afbb8d7ba8a2b5476f4add9a2bd084ae248a2b2 (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
(.module:
  [lux (#- or and)
   [data
    ["." text
     format]
    [collection
     ["." list ("#/." functor)]]]])

(def: #export (quote text)
  (-> Text Text)
  (format text.double-quote text text.double-quote))

(def: #export (block content)
  (-> Text Text)
  (format content text.new-line text.new-line))

(def: #export (plural singular)
  (-> Text Text)
  (format singular "(s)"))

(def: #export (sentence content)
  (-> Text Text)
  (format content "."))

(def: #export paragraph
  (-> (List Text) Text)
  (|>> (list/map ..sentence)
       (text.join-with text.new-line)))

(do-template [<name> <word>]
  [(def: #export <name>
     (-> (List Text) Text)
     (text.join-with (format ", " <word> " ")))]

  [or     "or"]
  [and    "and"]
  [and/or "and/or"]
  )

(type: #export Section
  {#title Text
   #content Text})

(def: #export (section value)
  (-> Section Text)
  (format (block (get@ #title value))
          (get@ #content value)))