Nested types and function composition