How to detect/avoid type piracy?

Hmm. Thank you for the nice write-up. I think I begin to understand your point better.

However, your example sets perfect ground for counter argument. Being able to put the most_interesting_operation under the same roof would allow developers to write something like:

map(most_interesting_operation, bag_of_vars)

that would work for any collection of variables whose types might not be even known in advance until run time.

Even better, I can write something like

twice_as_interesting(x) = x |> most_interesting_operation |> most_interesting_operation

And this will just work for all types for which the corresponding specialisation is exported. This is generic!

With the most_interesting_operations confined to their respective modules, the above becomes utterly impossible, isn’t it?

1 Like