Fix computation of function usage type

The tricky part is handling coercions.  The function applyContext
computes the type in an application context.  E.g., given

     newtype N = N (forall a. B -> a)
     f :: A -> N
     x :: A
     y :: B

then in the expression

     ((f x) `cast` N ~ forall a. B -> a) @C y

the usage type of `f` should be

     A -> B -> C

The (nested) context in this case will be:

    [[[[] x] `cast` N ~ forall a. B -> a] @C] y

We basically work inside-out:

    [f :: A -> N] x
     =>  A -> [[N] `cast` forall a. B -> a]
     =>  A -> [[forall a. B -> a] @C]
     =>  A -> [[B -> C] y]
     =>  A -> B -> C