Add forward propagation

This PR adds forward type propagation through function definitions with implicit arguments. This makes it much easier to declare recursive functions with implicit arguments.

The patch involves rewriting `type_implicit_arg` as `type_implicit_function` by merging some functionality that was previously within `type_expect_` and removing some unnecessary duplication between those two pieces of code.