Move unification to the types module. Use polymorphic variants for types to improve modularity.