Added base for AST type system, adapted from DH-acc newtypes-branch.