Updated typechecker with new algebra