Generating Code with Polymorphic let: A Ballad of Value Restriction, Copying and Sharing
Oleg Kiselyov (Tohoku University, Japan)

TL;DR
This paper explores the challenges of generating well-typed polymorphic let-expressions in languages with effects, introduces a new generator, and proposes a weaker restriction for let-polymorphism with practical implementation.
Contribution
It presents the first derivation of a polymorphic-let generator, a novel source-to-source transformation, and a weaker restriction for let-polymorphism in ML for code generation.
Findings
A polymorphic-let generator exists and can be derived.
A simple source-to-source transformation enables quotation in code generation.
A weaker restriction for let-polymorphism improves practical code generation in ML.
Abstract
Getting polymorphism and effects such as mutation to live together in the same language is a tale worth telling, under the recurring refrain of copying vs. sharing. We add new stanzas to the tale, about the ordeal to generate code with polymorphism and effects, and be sure it type-checks. Generating well-typed-by-construction polymorphic let-expressions is impossible in the Hindley-Milner type system: even the author believed that. The polymorphic-let generator turns out to exist. We present its derivation and the application for the lightweight implementation of quotation via a novel and unexpectedly simple source-to-source transformation to code-generating combinators. However, generating let-expressions with polymorphic functions demands more than even the relaxed value restriction can deliver. We need a new deal for let-polymorphism in ML. We conjecture the weaker restriction…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNatural Language Processing Techniques · Logic, programming, and type systems · Software Engineering Research
