Move the type constructs of enums to codegen.

The type of enumerations is still determined at parsing time. Only
it is stored as ADT and not as 'Type' from haskell-src-exts, the
translation is done when generating code.
Also delays creating the function types.

Creating the types of the functions is now delayed until code
generation. It also fixes the problem with duplicate type variables.