diff options
author | dos-reis <gdr@axiomatics.org> | 2008-08-23 08:28:49 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-08-23 08:28:49 +0000 |
commit | 5ec0094982b5c45d9d539e7bf9a9136aa40a9865 (patch) | |
tree | cbd1a63a013a3eb31e1a62ecc97b9ec0315f2102 /src/algebra | |
parent | 1d7938f6285b49350cef28838d1cf8744a4ef546 (diff) | |
download | open-axiom-5ec0094982b5c45d9d539e7bf9a9136aa40a9865.tar.gz |
* algebra/any.spad.pamphlet (Maybe): New domain.
* algebra/exposed.lsp.pamphlet: Expose it.
* algebra/Makefile.pamphlet (axiom_algebra_layer_1): Include MAYBE.
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/Makefile.in | 2 | ||||
-rw-r--r-- | src/algebra/Makefile.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/any.spad.pamphlet | 54 | ||||
-rw-r--r-- | src/algebra/exposed.lsp.pamphlet | 1 |
4 files changed, 54 insertions, 5 deletions
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index 14a4c8db..d0169a63 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -376,7 +376,7 @@ axiom_algebra_layer_1 = \ PATAB PPCURVE PSCURVE REAL RESLATC RETRACT \ RETRACT- SEGCAT BINDING SYNTAX BMODULE LOGIC \ LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- BYTE \ - OSGROUP + OSGROUP MAYBE axiom_algebra_layer_1_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_1)) diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet index c2f97a52..7170fa32 100644 --- a/src/algebra/Makefile.pamphlet +++ b/src/algebra/Makefile.pamphlet @@ -219,7 +219,7 @@ axiom_algebra_layer_1 = \ PATAB PPCURVE PSCURVE REAL RESLATC RETRACT \ RETRACT- SEGCAT BINDING SYNTAX BMODULE LOGIC \ LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- BYTE \ - OSGROUP + OSGROUP MAYBE axiom_algebra_layer_1_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_1)) 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>> diff --git a/src/algebra/exposed.lsp.pamphlet b/src/algebra/exposed.lsp.pamphlet index 2dec4c37..f9ba341c 100644 --- a/src/algebra/exposed.lsp.pamphlet +++ b/src/algebra/exposed.lsp.pamphlet @@ -222,6 +222,7 @@ (|MatrixCategoryFunctions2| . MATCAT2) (|MatrixCommonDenominator| . MCDEN) (|MatrixLinearAlgebraFunctions| . MATLIN) + (|Maybe| . MAYBE) (|MergeThing| . MTHING) (|ModularDistinctDegreeFactorizer| . MDDFACT) (|ModuleOperator| . MODOP) |