Easy Static Checking for Embedded DSLs in Scala with Contextual
summary
Library contextual produces compile-time checked interpolators for Scala by exposing literal parts to user code while handling the macro plumbing internally, so ordinary implicits and type classes define how holes are validated and escaped. It assigns a context per hole (scheme, domain, path, query, XML body/attribute) and can abort compilation with precise offsets and messages when parsing or semantic checks fail. Examples include URL, XML and CSS validators, optional runtime evaluation into java.net.URL, open source releases for Scala 2.10/2.11/2.12 and planned 2.0 API changes.
AI-written summary · about
chapters (41)
- 0:00Introduction
- 1:38What is Contextual
- 2:23Why Contextual interrupts are boring
- 3:32The Typer
- 5:35Why is it true
- 7:00How does it work
- 7:15Extension Methods
- 9:23Revisiting Extension Methods
- 11:05Contextual
- 13:08Examples
- 13:41Embedding in Scala
- 14:17Writing Interpolators
- 15:04Haskell
- 15:31Regular Expressions
- 15:45Use of Facing Messages
- 16:12Contextual Interpolators
- 16:36Object
- 17:03ID
- 18:44CSS Interpolator
- 19:28A horrible abomination
- 20:19XML
- 20:52XML Example
- 21:16Xylophone
- 21:34compile error
- 21:44check tags
- 24:04embed name
- 25:30preview
- 27:32embed type class
- 28:54check string content
- 29:24assign context
- 29:34pass position
- 30:06create object
- 30:22extension field
- 30:59literals method
- 33:19parses method
- 35:17dissect URL
- 35:54create case object
- 36:08compile
- 38:30substitution
- 40:27input types
- 44:15version number
related talks
33mStatically Typed Interpreters
42mLet the Compiler Help You: How to Make the Most of Scala's Type System
40mScala vs Idris: Dependent types, now and in the future
20mStatically Contextualizing Large Language Models with Typed Holes
33mThe Checker Framework In Action
50mImplicits Inspected and Explained
30mConstraint Typing with Boolean Algebra
49mIdris for (im)practical Scala programmers
