I don't like Union(SomeDomain, "failed") very much.
1) Since Union actually requires domains as arguments, there must be
some special compiler code dealing with that. In the long run, I would
like to either have a special domain Failed, which only has one element
called failed and which can be used as Union(D, Failed) or to have a
domain like Partial (see below).
2) I've tried to write a Partial domain, but with some problems.
---rhxBEGIN partial.spad
)abbrev domain PARTIAL Partial
Partial(V: Type): with
if V has CoercibleTo OutputForm then CoercibleTo OutputForm
inject: V -> %
retract: % -> V
failed: () -> %
failed?: % -> Boolean
== add
Rep := Record(val: V)
if V has CoercibleTo OutputForm then
coerce(x: %): OutputForm ==
failed? x => "failed"::Symbol::OutputForm
x.val :: OutputForm
inject(v: V): % == construct v
retract(x: %): V == x.val
failed: % == NIL$Lisp
failed?(x: %): Boolean == EQ(x, failed)$Lisp
---rhxEND partial.spad
(1) -> Integer has CoercibleTo OutputForm
(1) true
Type: Boolean
(2) -> Partial Integer has CoercibleTo OutputForm
(2) false
Type: Boolean
Any idea why I don't get true for (2)?
3) I actually would like something like in Aldor, i.e. that I can specify
failed: %
in the categorial part. But that doesn't work. Any chance that it can
work in some near future?
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.