Use currying to improve type inference

As per discussion in #1392.

/cc @headinthebox, @samuelgruetter