EDIT: I’ve misunderstood parts of the paper; please don’t miss the second post where I try to correct myself.
I’ve recently found an interesting paper called Let Should not be Generalised. It argues that Hindley-Milner languages don’t really need to implement let-polymorphism.
For uninitiated, let polymorphism allows you to write:
foo : (List Int, List Bool)
foo =
let
makeList : a -> List a
makeList x = [x]
in
(makeList 1, makeList True)
Without let polymorphism you’d get a compiler error along the lines of "makeList
has already been used with Int
, so you can’t use it with a Bool
!"
What do you (perhaps @evancz in particular) think about the paper’s proposal to ditch let polymorphism? Is it essential for some parts of the Elm ecosystem? Or could we simplify the language?
I’m still reading the paper, but it was surprising to read in particular that Haskell ecosystem doesn’t really need let-polymorphism (as much as thought previously):
We show that generalisation for local let bindings is seldom used; that is, if they are never generalised, few programs fail to typecheck (Section 4). We base this claim on compiling hundreds of public-domain Haskell packages, containing hundreds of thousands lines of code. Furthermore, those programs that do fail are readily fixed by adding a type signature.
Given I have yet to implement let-polymorphism in elm-in-elm
, I’m somewhat invested in this possibility And removing features from Elm does have some precedent already