Fix curried function application in code generation.

Two bugs manifested:
    - An off-by-one error in binds caused a type mismatch.
    - std::bind returns an object which, when called, returns the
      curried function.