Hacker News new | ask | show | jobs
by Tcepsa 6 days ago
Apologies for the slow reply; it has been a chaotic week!

The short answer is, "you don't"; without a strong type system you cannot ensure that clients always do the correct operations on your data. (Edit: A strong type system alone is not enough; it must also be correctly leveraged!)

The longer answer is, "Roughly the same way you do with less-strongly-typed languages like C or Java." You embrace Postal's Law/the Robustness Principle (thus try to do sensible things with the sorts of outputs you are likely to receive), you fail early and loudly with things that you cannot do sensible things with, you implement tests that demonstrate the various supported use-cases, you use clear variable names to the extent that you can, you provide guidance via documentation. With Clojure in particular, you can also do destructuring directly in the function signature, which provides additional clues as to what the arguments are expected to look like.