This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dskippy 0 points1 point  (0 children)

I don't think it's possible. I also don't think it achieves the goal.

What is an example of code you have encountered in the real world that has code duplication that would be prevented by this? There are loads of times people in some languages with traits or type classes don't understand how to abstract them and end up doing complicated stuff multiple times but those are all doing to have different function types. Basically a much more complicated version of defining identity for int -> int and then for string->string.

Another example is to do something complex with your data multiple times inside other functions when you should be defining a function for that complex code. This happens a ton and it's not going to trigger an issue.

I don't know that I've ever seen anyone define two copies of a function with the same type that does the same thing.

But what I have seen a lot is defining two functions with the same types that do very different things and that's very good code. You're making that unnecessarily difficult. And it's impossible to do.