Functional interpreters and you
summary
Compares two concrete interpreter encodings: a reified AST with pattern-match evaluators and AST-based free monads (implemented with Cats’ Free and foldMap to Future/Option/ID) versus a Church-encoded approach tagless final that returns F[A] so interpreters pick F (Future, ID, Either) and sequencing comes from a Monad instance. Builds a calculator DSL, demonstrates type-safe typed-DSL vs untyped, shows composition via EitherK and mentions Freestyle for boilerplate reduction, reports tagless-final is simpler, lighter and used in multiple projects with working GitHub examples.
AI-written summary · about
chapters (17)
- 0:00Start
- 0:34Interpreter Pattern
- 2:13The Interpreter Pattern
- 4:01Write Multiple Interpreters To Interpret a Program
- 5:05Compilers
- 5:26Use Cases
- 5:53Approaches to Interpreters
- 6:13Church Encoding
- 10:58An Asynchronous Interpreter
- 11:33Analysis and Recompilation
- 12:42Boolean Operators and Comparisons
- 17:19Implicit Ordering
- 18:26Flat Map Expression
- 29:49Helper Methods
- 33:27Alternative Encoding
- 37:59This Is a Bit of a Weird One but in Principle You Can Implement Anything You Want in There any Type of Structure You Want and Then in Your and Then the Other Thing Is that a Lot of these Guys I Haven't Introduced any any Sequencing in Here I'Ve Got a Wrote Square Bracket There That's a Bit Weird but I Haven't I Haven't Said How these Things Could Be Sequence Together and the Idea Is that When You Build One these Interpreters You Fill in a Data Type That Has some Kind of Sequencing in It so We Can Use a Monad
- 38:19I Haven't I Haven't Said How these Things Could Be Sequence Together and the Idea Is that When You Build One these Interpreters You Fill in a Data Type That Has some Kind of Sequencing in It so We Can Use a Monad so We Can Build a Program Which Says Okay I Can Run this Sequence of Steps for any Dsl for of an F Where F Is a Monad F Has an Instance of Monads so You Can Import that if You Import Monad and You Put this Cat Slot Syntax Dot Flatmap Then that Gives You this Flat Map Method on on F Whatever F Is So if I Want To Run It with Future I Pass in My a Secrets Interpreter
related talks
44mFunctional Interpreters and You
41mWhy the free Monad isn't free
43mFree monad or tagless final? How not to commit to a monad too early
33mAnalyzing Functional Programs
34mA Year living Freely
36mDo it with (free?) arrows!
37mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 6 of 6
46mInventing a language (placeholder title)
