Free monad or tagless final? How not to commit to a monad too early
summary
Claim: free monad and tagless final are equally expressive but trade off representation and ergonomics. Live‑coding converts a Future‑based loyalty‑points example into a free monad = programs as data implementation with a Future interpreter run via foldMap to interpret into Future, and into a tagless final = expressions parameterized by F version that requires a Monad constraint for flatMap. Shows interpreter code, combination-of-algebras boilerplate for coproducts, allocation and stack‑safety differences, and gives guidelines: free for librarylike descriptions, tagless for high‑level business code.
AI-written summary · about
chapters (20)
- 0:00Intro
- 1:08Scala code
- 15:10Future interpreter
- 16:10Find user ID
- 17:10Run program description
- 18:10Free monad solution
- 19:10Tagless final solution
- 21:10Making it work
- 22:10Comparing to original code
- 23:10Writing future interpreter
- 24:10Running future interpreter
- 25:10Stack safety
- 27:10Side effects
- 33:10Interpretation
- 34:10Summary
- 35:10Playing values
- 36:10Overhead
- 37:10Combining languages
- 38:10Free monad guidelines
- 39:10Tagless vs free
related talks
01h 14mBeyond Free Monads
41mWhy the free Monad isn't free
42mFunctional interpreters and you
32mDiscussion: Are Free Monads Really Free?
33mExtensible Effects: A Leaner Cake for Purely Functional Code
50mHierarchical Free Monads & Software Design in Functional Programming
45mHOW I UNDERSTOOD MONAD TRANSFORMERS
42mMonads you already use without knowing it
