Juan Manuel Serrano Hidalgo

Associate professor @ University Rey Juan Carlos, co-founder @ Habla Computing

Juan M. Serrano divides his time between the University Rey Juan Carlos and Habla Computing, a small consulting studio specializing in functional programming, data engineering, and kdb+/q. An active advocate for functional programming techniques for the last 12 years, he has organized numerous training sessions on functional programming with Scala.



The talk aims at describing a step-by-step process to embed external languages into strongly-typed functional languages, in close accordance with the guidelines of the tagless-final approach. The process encourages starting with simple embedding for fix domains, progressing towards more complex implementations that abstract the domain of interpretation using type classes, and leverage the static type system of the host language.

The talk also intends to show the advantages and limitations of the lastest Scala 3 features in regard to language embeddings. Particular attention will be paid to structural types and macros. 

Finally, we think the embedding of jq and its interplay with lower-level streaming languages, also seves as a good example of a functional architecture: an architecture buit around language standards decoupled from concrete frameworks.


Scala will be the sole language used throughout the talk, but we will take care of emphasizing common techniques and patterns (type classes, type systems, algebraic data types, etc.) that can be used with any strongly typed functional language. 

Although code examples will exploit medium-advance level techniques from Scala and functional programming, we will attempt to motivate what we are doing in order to attract the attention of less experience functional programmers.


Sooner or later, you'll find yourself wanting to create your own domain-specific language or embed an external DSL into your functional language of choice. This presentation delves into the motivations behind this choice and offers practical guidance on how to achieve it. Specifically, it will demonstrate the implementation of the syntax, semantics, and type system of DSLs using the tagless-final style, along with some of the latest Scala 3 features: extension methods, match types, union types, polymorphic function types, structural types, macros, and more. Real-world examples will be drawn from the Scala embedding of the command-line JSON quer language, jq.