Retain type hints when constructing a composed function