Next: Implementing Computer Algebra with ALDOR Up: An introduction to the ALDOR Previous: Domains

## Categories

• Every domain belongs to the type `Type`, but it is useful to be
able to assert more.
• Categories provide information about domain values, indicating what exports they must provide.
• A basic category-valued expression gives a list of exports:
```with { vertex: (%, Integer) -> Complex ;
new: List Complex -> % }
```
• Categories may be used in declarations.
```Polygon with { vertex: (%, Integer) -> Complex ;
new: List Complex -> %
} == add {
Rep == List Complex;
new(l: List Complex): % == per l;
vertex(p: %, i: Integer): Complex == rep(p).i;
}
```
• We may create category-valued constants.
```define Monoid: Category == with {
1: %;
*: (%, %) -> %
}
define Finite: Category == with {
cardinality: Integer
}
```
• The `Join` operator combines catgories, providing multiple inheritance:
```define FiniteMonoid: Category == Join(Monoid, Finite)
```
• One may use functions to compute categories:
```define Module(R: Ring): Category == Ring with {
*: (R, %) -> %
}

define ComplexCategory(R: Ring): Category ==  Module(R) with {
complex: (R, R) -> R;
real:    % -> R;
imag:    % -> R;
}
```

Next: Implementing Computer Algebra with ALDOR Up: An introduction to the ALDOR Previous: Domains
Marc Moreno Maza
2003-06-06