typing functions recursively