--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Sun Dec 18 10:09:38 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA24030; Sun, 18 Dec 1994 10:09:38 -0500
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 0201; Sun, 18 Dec 94 10:09:36 EST
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.BRONSTEI.NOTE.YKTVMV.1169.Dec.18.10:09:35.-0500>
--*           for asbugs@watson; Sun, 18 Dec 94 10:09:35 -0500
--* Received: from inf.ethz.ch by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Sun, 18 Dec 94 10:09:35 EST
--* Received: from ru7.inf.ethz.ch (bronstei@ru7.inf.ethz.ch [129.132.12.16]) by inf.ethz.ch (8.6.9/8.6.9) with ESMTP id QAA12191 for <asbugs@watson.ibm.com>; Sun, 18 Dec 1994 16:09:36 +0100
--* From: Manuel Bronstein <bronstei@inf.ethz.ch>
--* Received: (bronstei@localhost) by ru7.inf.ethz.ch (8.6.8/8.6.6) id QAA10119 for asbugs@watson.ibm.com; Sun, 18 Dec 1994 16:09:35 +0100
--* Date: Sun, 18 Dec 1994 16:09:35 +0100
--* Message-Id: <199412181509.QAA10119@ru7.inf.ethz.ch>
--* To: asbugs@watson.ibm.com
--* Subject: [1] conditional default not found

--@ Fixed  by:  SSD   Mon Mar 20 08:54:10 EST 1995 
--@ Tested by:  none 
--@ Summary:    Fixes to inheritance of conditional defaults. 

-- Command line: asharp -M2 baddef.as
-- Version: 1.0.3
-- Original bug file name: baddef.as

----------------------------- baddef.as ----------------------------------
-- asharp -M2 baddef.as
-- "baddef.as", line 33: MyType(R:Ring): MyCat2 R == add {
--                       ............................^
-- [L25 C29] #1 (Error) The domain is missing some exports.
--         Missing gcd: (%, %) -> %
--         Missing rem: (%, %) -> %
--

#include "aslib.as"

MyCat1(R:Ring):Category == Ring with {
	coerce:	R -> %;
	default {
		coerce(n:Integer):%		== { import from R; n::R::%; }
		coerce(n:SingleInteger):%	== { import from R; n::R::%; }
		sample:%			== 1;
	}
}

MyCat2(R:Ring):Category == MyCat1 R with {
	if R has Field then EuclideanDomain;
	default {
		if R has Field then {
			(a:%) quo (b:%):% == { (q, r) := divide(a, b); q; }
			(a:%) rem (b:%):% == { (q, r) := divide(a, b); r; }
			divide(p:%, q:%):(%, %) == (0, p);
			gcd(p:%, q:%):% == 1;
		}
	}
}

MyType(R:Ring): MyCat2 R == add {
	macro Rep == R;

	import from Rep;

	0:%	== per 0;
	1:%	== per 1;
	coerce(r:R):% == per r;
	-(p:%):% == p;
	(x:%) = (y:%):Boolean == false;
	(p:%) + (q:%):% == p;
	(p:%) * (q:%):% == p;
	(p:%) ^ (n:Integer):% == p;
	(port:TextWriter) << (p:%):TextWriter   == port;
}
 
