aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/meta/type/unit.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/meta/type/unit.lux89
1 files changed, 89 insertions, 0 deletions
diff --git a/stdlib/source/documentation/lux/meta/type/unit.lux b/stdlib/source/documentation/lux/meta/type/unit.lux
new file mode 100644
index 000000000..1f2f6918e
--- /dev/null
+++ b/stdlib/source/documentation/lux/meta/type/unit.lux
@@ -0,0 +1,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]
+ ))]
+ [])))