Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/base.xml45
1 files changed, 37 insertions, 8 deletions
diff --git a/core/base.xml b/core/base.xml
index 78b4ed0..099055b 100644
--- a/core/base.xml
+++ b/core/base.xml
@@ -80,14 +80,6 @@
</typedef>
- <typedef name="boolean" desc="Boolean values">
- <enum type="integer">
- <item name="TRUE" value="1" desc="True" />
- <item name="FALSE" value="0" desc="False" />
- </enum>
- </typedef>
-
-
\ref{empty} does not have much use outside of the compiler.
<typedef name="empty"
@@ -98,6 +90,43 @@
</section>
+ <section title="Boolean and Unknown">
+ \ref{boolean} contains the boolean \ref{TRUE} and~\ref{FALSE} values,
+ which map to~$1$ and~$0$ respectively.
+ The \ref{maybe} type is the union of \ref{boolean} and \ref{NOTHING},
+ with a value of~$-1$;\footnote{
+ This is similar in spirit to the Haskell \tt{Maybe} type,
+ or the OCaml \tt{Option} type.
+ }this is commonly used to represent an unknown state or missing
+ value.\footnote{
+ The \ref{nothing}~type is used for the sake of the union;
+ it should not be used directly.}
+
+ <typedef name="maybe" desc="Boolean or unknown value">
+ <union>
+ <typedef name="nothing" desc="Unknown value">
+ <enum type="integer">
+ <item name="NOTHING" value="-1" desc="Unknown or missing value" />
+ </enum>
+ </typedef>
+
+ <typedef name="boolean" desc="Boolean values">
+ <enum type="integer">
+ <item name="TRUE" value="1" desc="True" />
+ <item name="FALSE" value="0" desc="False" />
+ </enum>
+ </typedef>
+ </union>
+ </typedef>
+
+ The constant \ref{UNKNOWN} is also defined as~$-1$ to serve as an
+ alternative to the term~``nothing''.
+
+ <const name="UNKNOWN" value="-1"
+ desc="Unknown or missing value" />
+ </section>
+
+
<section title="Convenience">
$0$~is a~common value. Where a value is required (such