Add parametric types

This is based on @martint 's compiler branch, so ignore everything except the last commit