External Publication
Visit Post

Final call for GHC String Interpolation proposal!

Haskell Community [Unofficial] June 10, 2026
Source

Call me crazy, but I think the absence of convenient string interpolation syntax in Haskell is actually a good thing. Hear me out.

Naive string interpolation, that is, injecting generic string representations of arbitrary Haskell values into strings, is rarely conceptually correct - in almost all situations, the resulting strings are supposed to adhere to some kind of structural rules or constraints, i.e., some kind of grammar, and the injected values are supposed to be contained to some sort of “value” concept within that grammar. Naive string interpolation cannot ensure this - there’s no way to make sure the injected string does not “escape” the grammar, changing the structure of the template rather than just filling a blank within it.

This is not a theoretical concern. Naive string interpolation causes bugs, security disasters, and other pains, all the time in languages that have them. Just some examples off the top of my head:

  • Anyone who has ever done anything nontrivial in Bash can testify that dealing with whitespace in variables correctly is unreasonably difficult, especially when those variables are interpolated into strings (which is extremely common in Bash scripts).
  • XSS is still running rampant in PHP, a language that has string interpolation baked into the fabric of the language.
  • SQLi is still a major problem in any language that has convenient string interpolation language, because it is marginally more convenient than using the proper solution, parametrized queries.

I am actually hard pressed to think of an example where naive string interpolation is morally correct - even the classic “greeter” program (ask user for their name, greet them with "Hello, ${name}") is technically wrong, which is easily demonstrated by providing names that contain things like backspaces, newlines, carriage returns, terminal control sequences, etc.

Discussion in the ATmosphere

Loading comments...