I am satisfied now:
-------------------------------------------------------------------------------
#include "axiom"
MyMonoid(T: Type, m: (T, T) -> T): Category == with {
square: T-> T;
default {square(t: T): T == m(t, t)}
}
MyWord: with {
coerce: String -> %;
c:(%, %) -> %
}
== add {
Rep == String;
import from String;
coerce(a: String): % == per(a);
c(a: %, b: %):% == coerce(concat(rep(a), rep(b))$String) }
import from MyWord;
extend MyWord: MyMonoid(MyWord, c) == add;
-------------------------------------------------------------------------------
The only slight inconvenience is that we need to have the domain itself as
parameter of the category, too. But I think that's ok, given that there is no
need to change the compiler in any way. I'll post this on SandboxMonoid as
well.
-------------------------------------------------------------------------------
AXIOM Computer Algebra System
Version: Axiom 3.9 (September 2005)
Timestamp: Monday October 31, 2005 at 16:30:26
-----------------------------------------------------------------------------
Issue )copyright to view copyright notices.
Issue )summary for a summary of useful system commands.
Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------
Re-reading compress.daase Re-reading interp.daase
Re-reading operation.daase
Re-reading category.daase
Re-reading browse.daase
(1) ->
(1) -> )co test.as
(1) -> )sh MyMonoid
MyMonoid(T: Type,m: ((T,T) -> T)) is a category constructor
Abbreviation for MyMonoid is MYMONOI
This constructor is exposed in this frame.
Issue )edit test.as to see algebra source code for MYMONOI
------------------------------- Operations --------------------------------
square : T -> T
(1) -> )sh MyWord
MyWord is a domain constructor
Abbreviation for MyWord is MYWORD
This constructor is exposed in this frame.
Issue )edit test.as to see algebra source code for MYWORD
------------------------------- Operations --------------------------------
c : (%,%) -> % coerce : String -> %
square : MyWord -> MyWord
(1) -> a := "Bingo"::MyWord
LISP output:
Bingo
Type: MyWord
(2) -> square a
LISP output:
BingoBingo
Type: MyWord
(3) -> MyWord has MyMonoid(MyWord, c)
(3) true
_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer