| ▲ | kaoD 2 hours ago | |
> Suddenly this typing problem goes away, because the type of your "flatten" method is just "MyStructure -> [MyElements]". How is that less maintenance burden than a simple Flatten type? Now you have to construct and likely unwrap the types as needed. And how will you ensure that you're flattening your unneeded type anyways? Sure you can remove the generics for a concrete type but that won't simplify the type. It's simple. It's just recursive flattening an array in 4 lines. Unlikely to ever change, unlike the 638255 types that you'd have to introduce and maintain for no reason. There are many reasons not to do that. Say your business logic changes and your type no longer needs one of the alternatives: you are unlikely to notice because it will typecheck even if never constructed and you will have to deal with that unused code path until you realize it's unused (if you ever do). You made code harder to maintain and more complex for some misguided sense of simplicity. | ||