Ralf Hemmecke <[EMAIL PROTECTED]> writes: > As I said. Your "add {...}" thing considered as an anonymous domain exports > *nothing*.
The AUG says on page 84 The value of the expression A add B is a domain which exports those symbols exported by A and those exports defined in B. The type of the expression A add B is C with { x1: T1; ...; xn: Tn } where C is the type of A, and x1,...,xn are the symbols defined (using ==) in B, whose types are T1,...,Tn, respectively. and on page 105 The "add" operator has the following syntax: Add-domain add declarations It combines a group of declarations with a (possibly omitted) domain, to form a new type (see Section 7.8). Declarations on the right hand side of the add are marked as being exports of the new type, provided that they are not explicitly defined as local. So, let's consider getit(T: Category, L: Tuple T, i: MachineInteger): T == add { element(L, i)$Tuple(T); } I think the right hand side of the "==" should export "element(L,i)$Tuple(T)", which is of type T, which in turn agrees with the left hand side. So, I'd expect that getit(OutputType, (Integer, Boolean), 1) is a domain of type OutputType. Did I make a mistake? > What you probably want is > > getit(T: Category, L: Tuple T, i: MachineInteger): T == { > import from Tuple T; > element(L, i); > } > > without the "add" or perhaps (if the former does not work) somthing like > > ... == { > import from Tuple T; > element(L, i) add; > } > > but I don't know whether that is something that is supposed to work. Curiously, neither of the two "works". The first variant leads to "Bad use of a dependent type", while the second doesn't even compile: "There are no suitable meanings for the operator `element'. The following could be suitable if imported: element: (Tuple(T), MachineInteger) -> T from Tuple(T)". (sic!) The following variation seems to be equivalent to my original code: ... == { { element(L, i)$Tuple T } add; } Interestingly, the following works just as I'd think it should. Note that Aldor realizes that t has OutputType! #include "aldor" #include "aldorio" getit(T: Category, D: T): T with { make: D -> %; get: % -> D; } == add { D; Rep == D; make(x: D): % == per x; get(y: %): D == rep y; } import from Integer, Boolean, List OutputType; t == getit(OutputType, Integer); a := make(1783)$t; stdout << get(a)$t << newline; Martin ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Aldor-combinat-devel mailing list Aldor-combinat-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/aldor-combinat-devel