Refactor the way we infer types for functions in a mutually recursive group