Fix bug where a lambda-bound argument was not monomorphic in the body of the lambda

For example, this code should not type-check
    data Pair a b = Pair a b;
    id x = x;
    f g p = case p of { Pair a b -> Pair (g a) (g b); };
    main = f id (Pair 1 True)

The type of f should be forall a b. (a -> b) -> Pair a a -> Pair b b
because the argument g must be monomorphic inside the body of f.

We were instead generating a malformed type
forall a b c d. (a -> b) -> Pair a c -> Pair b d

This was happening because we were failing to correctly update the type
environment while typechecking an application.

The code now fails to typecheck with the following message (as expected):
    Type Error:
            Cannot unify 'Int' and 'Bool'
        in:
            main = f id (Pair 1 True)

The code will typecheck if we change one of the components of the Pair in main:
    main = f id (Pair 1 6)
Add test for last commit