As my newsletter subscribers suspect and my Ensō colleagues already know by now, I’ve recently started writing a book. Not just any book—a practical guide for React developers who want to learn functional programming the right way, without getting lost in academic theory or Haskell’s notorious learning curve.
The working title is “An Elm Primer for React Developers: The Best Way to Learn Real Functional Programming”, and yes, that’s a bold claim. Let me explain why I believe it.
Why Elm? Why Now? Link to heading
If you’ve been reading my blog, you know I’ve spent years writing React. Some of my most popular posts dive deep into React’s internals—React.memo
, reconciliation, performance optimization. Those articles have been used in React courses and even translated to Korean (true story!). That popularity reflects something important: React is powerful, but its complexity increases dramatically once you step beyond the basics.
But here’s what I’ve discovered: Elm is the most effective path for developers (especially React developers) to learn functional programming—more so than Haskell or other FP languages.
Why? Because:
- Small, focused language: The entire language fits in your head—no academic ceremony
- Impossible to cheat: Mutation is literally impossible, not just discouraged—forces genuine FP thinking
- Limited to one platform/domain: …And a familiar one at that: it compiles to JavaScript running in your browser. The DOM is no stranger!
- Pure discipline without distractions: No lazy evaluation complexities (I’m looking at you,
foldr
vsfoldr'
!), no scary computer science jargon - Production-ready learning: You’re building real UIs, not solving academic exercises
- Concepts that transfer: The FP fundamentals (immutability, pure functions, explicit effects) apply directly to Haskell, F#, OCaml, Clojure, and will even help you in JavaScript
And here’s the kicker: if you understand React reducers and immutability patterns, you’re already halfway there.
The Book’s Promise Link to heading
Whether you end up using Elm professionally or not, learning Elm will make you a better developer in any language. It’s the most effective way to internalize functional programming without getting lost in academic complexity.
This book isn’t about convincing you to abandon React. It’s a guided tour: what Elm looks like, how it compares, and how you might start using Elm—even if only as a single widget inside a React app.
A Taste of What Makes Elm Special Link to heading
To give you a taste of what I mean by Elm’s guarantees, let me show you an example. Throughout the book, you’ll see what I call “Elm Hooks” in each chapter—compelling previews of what makes Elm delightful for that particular topic. React has hooks for state management, but Elm has hooks that keep you hooked on the language itself.
Here’s one right away, showcasing two of Elm’s main selling points: the friendly compiler and the strict type system (or, good cop / bad cop, if you prefer).
Elm Hook: Exhaustive Pattern Matching
Given the following Elm code:
type Animal = Cat | Dog | Penguin animalToString : Animal -> String animalToString animal = case animal of Dog -> "dog" Cat -> "cat" -- Ooops, forgot about that Penguin!
The compiler responds:
-- MISSING PATTERNS --------------- /Users/cekrem/code/animals/src/Main.elm This `case` does not have branches for all possibilities: 306|> case animal of 307|> Dog -> 308|> "dog" 309|> 310|> Cat -> 311|> "cat" Missing possibilities include: Penguin I would have to crash if I saw one of those. Add branches for them! Hint: If you want to write the code for each branch later, use `Debug.todo` as a placeholder. Read <https://elm-lang.org/0.19.1/missing-patterns> for more guidance on this workflow.
Sure beats all those
ensureNever
helpers you’ve written in TypeScript, huh?
What’s Next Link to heading
The book is currently in early access on Leanpub. I’ll be publishing chapters as I complete them, following the serial publishing model that worked so well for other technical books.
I’ll also be releasing select chapters here on my blog over the coming months. Chapter 2 compares The Elm Architecture to React patterns using a side-by-side Hangman game implementation—it’s a great practical introduction to how differently Elm approaches state management.
If you’re interested in following along:
- Subscribe to my newsletter (below)
- Check out the book on Leanpub for early access
- Stay tuned for more chapters here on the blog
Whether you’re curious about functional programming, frustrated with React’s complexity, or just want to expand your horizons, I think you’ll find this journey worthwhile. Elm changed how I think about code—not just in Elm, but in every language I write. I hope to share that experience with you.
More about the Book Link to heading
Working Title: An Elm Primer for React Developers: The Best Way to Learn Real Functional Programming
Status: Early access / In progress – I’ve so far drafted about 4 chapters, and outlined a few more
Target Audience: React developers with varying levels of experience who are curious about functional programming
What Makes It Different:
- Written specifically for React developers, using familiar concepts as bridges
- Practical, production-focused examples
- Emphasis on learning transferable FP concepts, not just Elm syntax
- Shows how to integrate Elm incrementally into existing React codebases
Thanks for reading, and I hope you’ll join me on this exploration of what frontend development can look like when the compiler truly has your back.
As a reward for reading all the way down, here’s a sample containing (wip!) Table of Contents + intro and first chapter: An Elm Primer for React Developers (draft!)