aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/type/unit.lux
blob: c7f4948ab1eca6c457f0c9f8812f0ce515e001fe (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(.require
 [library
  [lux (.except and)
   ["$" documentation]
   [data
    ["[0]" text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]
   [math
    [number
     ["[0]" ratio]]]]]
 [\\library
  ["[0]" /]])

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [($.default /.Gram)
             ($.default /.Meter)
             ($.default /.Litre)
             ($.default /.Second)
             ($.default /.pure)
             ($.default /.number)
             ($.default /.equivalence)
             ($.default /.order)
             ($.default /.enum)
             ($.default /.Kilo)
             ($.default /.Mega)
             ($.default /.Giga)
             ($.default /.Milli)
             ($.default /.Micro)
             ($.default /.Nano)
             ($.default /.+)
             ($.default /.-)
             ($.default /.*)
             ($.default /./)

             ($.documentation (/.Measure unit)
               "A quantity with an associated unit of measurement.")

             ($.documentation (/.Unit unit)
               "A unit of measurement, to qualify numbers with.")

             ($.documentation (/.Scale scale)
               "A scale of magnitude.")

             ($.documentation /.Pure
               "A pure, unit-less measure.")

             ($.documentation /.unit
               (format "Define a unit of measurement."
                       \n "Both the name of the type, and the name of the Unit implementation must be specified.")
               [(def feet (unit []))])

             ($.documentation /.scale
               "Define a scale of magnitude."
               [(def bajillion (scale [1 1,234,567,890]))])

             ($.documentation /.re_scaled
               ""
               [(re_scaled from to measure)])

             (~~ (with_template [<type> <scale>]
                   [(`` ($.documentation <scale>
                          (let [numerator (the [/.ratio ratio.#numerator] <scale>)
                                denominator (the [/.ratio ratio.#denominator] <scale>)]
                            (format "The '" (~~ (template.text [<scale>])) "' scale, from " (%.nat numerator) " to " (%.nat denominator) "."))))]

                   [/.Kilo /.kilo]
                   [/.Mega /.mega]
                   [/.Giga /.giga]

                   [/.Milli /.milli]
                   [/.Micro /.micro]
                   [/.Nano /.nano]
                   ))

             (~~ (with_template [<unit>]
                   [(`` ($.documentation <unit>
                          (format "The '" (~~ (template.text [<unit>])) "' unit of meaurement.")))]

                   [/.gram]
                   [/.meter]
                   [/.litre]
                   [/.second]
                   ))]
            []))