Skip to content

Instantly share code, notes, and snippets.

TL/DR Not every type hole is harmful.

[Disclaimer: The following code is typed with scriptum, a type validator for dynamically typed Javascript. It has its roots in Haskell's Hindley-Milner based type system.]

It helps to consider mutations to get a better intuition. Mutations are a side effect and thus harmful. However, if we manage to hedge side effects so that we don't lose track of them, then we can benefit from the flexibility they provide without having to suffer the consequences.

For mutations this merely essentially means ensuring they stay local. Local mutations are fine in most cases. The same applies to type holes.

Let's work through some code to see if this claim holds. Gradual typing is a trade-off. Good coding means to find the most promising trade-offs.