Re: [open-axiom-devel] [fricas-devel] this domain %
A system for computer algebra and symbolic mathematics
Brought to you by:
dos-reis
From: Bill P. <bil...@ne...> - 2011-12-02 16:06:04
|
Bertfried, In FriCAS you should make the following change (:= instead of == and explicitly define rep and per): Rep := List T rep(x:%):Rep == x pretend Rep per(x:Rep):% == x pretend % But as I mentioned in my email to Gaby this code does not compile in FriCAS. It does compile and run in OpenAxiom. I haven't tried with old Axiom yet. Here is another variant that works in OpenAxiom but still fails in FriCAS where I have just replaced 'MySet %' with 'MySet MySet T'. As I understand it, this is now syntactically equivalent in OpenAxiom. I am not sure if this is the case in FriCAS. )abbrev domain MYSET MySet MySet(T:SetCategory): SetAggregate(T) with finiteAggregate join: MySet MySet T -> MySet T == add Rep == List T --rep(x:%):Rep == x pretend Rep --per(x:Rep):% == x pretend % Rep2 := List List T rep2(x:MySet MySet T):Rep2 == x pretend Rep2 per2(x:Rep2):MySet MySet T == x pretend MySet MySet T coerce(x:%):OutputForm == brace [i::OutputForm for i in rep x] x = y == rep(x) = rep(y) construct(x) == per removeDuplicates(x)$Rep parts(x:%):List T == rep x join x == construct concat rep2 x -- Perhaps as you know the point of this exercise was to be able to write 'MySet MySet T' (or equivalent) in the definition of MySet itself. There are still many functions missing in this definition. Of course as a functor we also need the equivalent of fmap, etc. Then my goal was to abstract the part of the definition involving join and return as a Monad category. Cheers, Bill Page. On Fri, Dec 2, 2011 at 10:44 AM, Bertfried Fauser <ber...@go...> wrote: > Dear Bill, > > Your code (which I copied and pasted into monad2.spad): > >> Here is some more realistic example code that does compile and run: >> >> )abbrev domain MYSET MySet >> MySet(T:SetCategory): SetAggregate(T) with >> finiteAggregate >> join: MySet % -> MySet T >> == add >> Rep == List T >> --rep(x:%):Rep == x pretend Rep >> --per(x:Rep):% == x pretend % >> >> Rep2 := List List T >> rep2(x:MySet(%)):Rep2 == x pretend Rep2 >> per2(x:Rep2):MySet(%) == x pretend MySet(%) >> >> coerce(x:%):OutputForm == brace [i::OutputForm for i in rep x] >> x = y == rep(x) = rep(y) >> construct(x) == per removeDuplicates(x)$Rep >> parts(x:%):List T == rep x >> join x == construct concat rep2 x >> > > (1) -> )co monad2 > Compiling FriCAS source code from file > /home/fauser/fricas/monad2.spad using old system compiler. > MYSET abbreviates domain MySet > ------------------------------------------------------------------------ > initializing NRLIB MYSET for MySet > compiling into NRLIB MYSET > compiling local rep2 : MySet $ -> Rep2 > MYSET;rep2 is replaced by x > Time: 0.03 SEC. > > compiling local per2 : Rep2 -> MySet $ > MYSET;per2 is replaced by x > Time: 0 SEC. > > compiling exported coerce : $ -> OutputForm > Internal Error > Error while instantiating type MySet$$ > > ? > Cheers > BF. > > > -- > % PD Dr Bertfried Fauser > % Research Fellow, School of Computer Science, Univ. of Birmingham > % Honorary Associate, University of Tasmania > % Privat Docent: University of Konstanz, Physics Dept > <http://www.uni-konstanz.de> > % contact |-> URL : http://www.cs.bham.ac.uk/~fauserb/ > % Phone : +44-121-41-42795 |