Improve type.Table. Validate types.

Depends on #24.

### Type:
* Rewrite of `Table`:
  * Don't create new `Type` objects; reuse AST nodes.
  * Store type info using only dictionaries; leverage `__eq__` and `__hash__` of the respective AST nodes.
  * Simplify code: use `try` blocks instead of double checking.
  * Allow cross-referencing of user-defined types and constructors to ease type inference.
* Add type validation.
* Fix bad line info in error message.

### Tests:
* Add complete suite of unit tests for `type` module.
Ambiguous test; what are you testing here? This will fail because you have a `ref` ton an `array`, while it seems to test that `array` to `array` is not allowed nested.