Contextual Easy, Compile-time String Interpolation Without Macros!
summary
Library named contextual gives compile-time validation for custom string interpolators, letting the compiler accept or abort literal patterns (XML, URLs, CSS, JSON, etc.) and enforce where and which types may be embedded. It exposes an extensible embedding API via implicits/type classes, runs a macro-phase early in the build to inspect literals, and produces runtime constructors only for code that passed checks. Claim of “without macros” contradicts the implementation — a macro does run. Version 1.0.1 is available.
AI-written summary · about
chapters (17)
- 0:00Introduction to contextual
- 1:52Basics of string interpolation
- 5:50How interpolators compile
- 8:24Macros for interpolation
- 12:01XML interpolation examples
- 21:38Advanced XML checks
- 24:03Embedding custom types
- 27:10Type class embedding
- 29:01Building a URL interpolator
- 31:49Defining the interpolator object
- 33:15Contextualizing holes
- 36:10Runtime interpolation
- 38:40Embedding and escaping
- 40:23Macro details and trade-offs
- 41:26Summary and benefits
- 43:55Preventing invalid types
- 44:15Resources and Q&A
