Gert-Jan Bottu, Richard Eisenberg. Haskell 2021. Seeking Stability by being Lazy and Shallow: Lazy and shallow instantiation is user friendly.
It is often the case that designing a language feature requires an arbitrary choice between two possibilities,both of which are similarly expressive. Given that proper scientific user studies are generally impractical, wepropose usingstabilityas a way of making this decision. Stability is a measure of whether the meaning of aprogram alters under small, seemingly innocuous changes in the code.
Directly motivated by a need to pin down a feature in GHC/Haskell, we apply this notion of stability to analyse four approaches to the instantiation of polymorphic types, concluding that the most stable approachis lazy (instantiate a polytype only when absolutely necessary) and shallow (instantiate only top-level typevariables, not variables that appear after explicit arguments). Our analysis is applicable and relevant to anyfunctional language that mixes implicit and explicit instantiation and generalisation.