aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/any.spad.pamphlet
diff options
context:
space:
mode:
Diffstat (limited to 'src/algebra/any.spad.pamphlet')
-rw-r--r--src/algebra/any.spad.pamphlet54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/algebra/any.spad.pamphlet b/src/algebra/any.spad.pamphlet
index e0e93817..af9c3f2e 100644
--- a/src/algebra/any.spad.pamphlet
+++ b/src/algebra/any.spad.pamphlet
@@ -1,14 +1,16 @@
\documentclass{article}
\usepackage{axiom}
\begin{document}
-\title{\$SPAD/src/algebra any.spad}
-\author{Robert S. Sutor}
+\title{src/algebra any.spad}
+\author{Robert S. Sutor \and Gabriel Dos~Reis}
\maketitle
+
\begin{abstract}
\end{abstract}
-\eject
+
\tableofcontents
\eject
+
\section{domain NONE None}
<<domain NONE None>>=
)abbrev domain NONE None
@@ -31,6 +33,50 @@ None():SetCategory == add
x:% = y:% == EQ(x,y)$Lisp
@
+
+
+\section{The Maybe domain}
+<<domain MAYBE Maybe>>=
+)abbrev domain MAYBE Maybe
+++ Author: Gabriel Dos Reis
+++ Date Created: August 20, 2008
+++ Also See: Union(T,"failed")
+++ Description:
+++ This domain implements the notion of optional vallue, where
+++ a computation may fail to produce expected value.
+++ Note: Ideally, this domain definition should be a one-liner.
+++ That is currently impossible because of mismatch between
+++ the `old representation' and `new representation' for domains.
+Maybe(T: CoercibleTo OutputForm): Public == Private where
+ Public == Join(UnionType,CoercibleTo OutputForm) with
+ _case: (%,[| T |]) -> Boolean
+ ++ x case T returns true if x is actually a data of type T.
+ _case: (%,[| nothing |]) -> Boolean
+ ++ x case nothing evaluates true if the value for x is missing.
+ coerce: T -> %
+ ++ x::T injects the value x into %.
+ coerce: % -> T
+ ++ x::T tries to extract the value of T from the computation x.
+ ++ Produces a runtime error when the computation fails.
+ autoCoerce: % -> T
+ ++ same as above but implicitly called by the compiler.
+ nothing: %
+ ++ represents failure.
+ Private == add
+ Rep == Union(T,"nothing")
+ nothing == per("nothing"::Rep)
+ coerce(x: T): % == per(x::Rep)
+ coerce(x: %): T == rep(x)::T
+ autoCoerce x == rep(x)::T
+ x case T == rep x case T
+ x case nothing == rep x case "nothing"
+ coerce(x: %): OutputForm ==
+ x case T => x::T::OutputForm
+ paren(empty()$OutputForm)$OutputForm
+@
+
+
+
\section{package NONE1 NoneFunctions1}
<<package NONE1 NoneFunctions1>>=
)abbrev package NONE1 NoneFunctions1
@@ -57,6 +103,7 @@ NoneFunctions1(S:Type): Exports == Implementation where
coerce(s:S):None == s pretend None
@
+
\section{domain ANY Any}
<<domain ANY Any>>=
)abbrev domain ANY Any
@@ -473,6 +520,7 @@ Environment(): Public == Private where
-- may be Any.
<<domain NONE None>>
+<<domain MAYBE Maybe>>
<<package NONE1 NoneFunctions1>>
<<domain ANY Any>>
<<package ANY1 AnyFunctions1>>