In Functional Marmalade, Patrik Andersson presents Marmalade — a functional programming language he’s building in Rust to better understand compilers, type systems, and FP fundamentals. Inspired by ML- and Haskell-style design, Marmalade features type inference ,sum/product/recursive types, pattern matching with exhaustiveness checks, and curried functions with first-class lambdas. Through examples like `perhaps` (Option/Maybe), `result` (Either/Result), and list processing with `foldRight`, Patrik shows how functional abstractions reduce repetition and increase correctness. The talk is both a technical deep-dive and a learning journey — driven by curiosity and the goal of making powerful concepts feel delightfully “magical.”
Functional Marmelade: A comprehensive overview
From Java confidence to functional “Ego Death”
Patrik’s story starts in a familiar place: early confidence as a Java developer, followed by the humbling experience of discovering functional programming.
He was introduced to Scala around 2009, initially disliked it, then returned in 2010 and went deep — progressing through:
- Scala and functional style
- Haskell and ML-family languages
- Lambda calculus
- Category theory
- Type systems and the kind of concepts you don’t even know exist until you hit them
He described this as a kind of “ego death” — the healthy realization that there is always more depth, more structure, and more to learn.
Today, Rust is his current obsession — and building Marmalade is partly a way to become very good at Rust by tackling increasingly difficult projects.
Why build a language at all?
Patrik’s motivation was simple and deeply relatable:
“We use compilers all day long. How do they work?”
He wanted to understand:
- parsing
- interpreters
- type inference
- type checking
- recursion
- closures
- pattern matching internals
Silt gave him a start (an imperative language without a type checker). Marmalade was the next challenge: a functional language with a real type system.
What is Marmalade?
Marmalade is a functional language inspired by the ML family (Standard ML, OCaml, F#) and influenced by Haskell — but with an emphasis on a more regular, uniform look and feel, where different constructs “look more similar than different.”
At its core, Marmalade is built on ideas from System F, with:
- Sum types and product types
- Recursive types
- Let-polymorphism (rank-1 types)
- Explicit parametric polymorphism with implicit instantiation
- Type inference (no annotations required for most code)
- Optional type signatures for top-level declarations
And yes — Patrik wanted the Greek symbols, because… obviously.
Type safety as a first-class feature
A major part of the talk focused on why adding a type checker changes everything.
In Marmalade:
- the compiler can infer types like `int`, `text`, and function types automatically
- type errors are caught early (e.g., adding an integer to a string)
- pattern matches can be checked for exhaustiveness and usefulness
Patrik also gave a glimpse into what makes type inference feel like “dark magic”: the compiler doesn’t just label types — it unifies them, producing substitutions like:
“Every time you see α, substitute it with int.”
This is the machinery that allows a type system to understand deeply nested expressions and curried function calls — even when the programmer doesn’t annotate anything.
The functional toolkit: Pattern matching, ADTs, and curried functions
Marmalade includes many of the defining features of FP languages:
Sum types (“co-products”)
Patrik introduced types like:
- `perhaps` (analogous to `Option` / `Maybe`)
- `result` (analogous to `Either` / `Result`)
…but in Marmalade they’re called “perhaps” and “return/fault” — because naming is part of the fun.
Pattern matching
Pattern matching is treated as a core feature, supporting:
- deep destructuring
- recursive patterns
- exhaustiveness checking (missing `nada/nope` cases becomes an error)
- unreachable clause detection (catch-all too early becomes a warning/error)
This is where Marmalade starts to feel powerful: you can write expressive code, and the compiler helps ensure it’s complete and coherent.
Currying and partial application
All functions are lambdas. Functions are curried by default. And partial application “just works” like in Haskell and F#.
Lists, folds, and “Code Golfing to 9000”
Toward the end, Patrik explored lists — because no FP talk is complete without them.
Marmalade defines a polymorphic recursive list type:
- `nil` for empty
- `cons` for head + tail
From there he implemented classic functions like:
- `head` returning `perhaps a` (because head of empty list is not safe)
- `map`, `length`, and then **foldRight**
Once foldRight existed, many list operations could be defined by composition rather than repetition. This led into a playful segment on “code golfing” — shrinking functions through techniques like eta-reduction and partial application until they became almost pure algebra.
The point wasn’t minimalism for its own sake — it was to show how functional abstractions let you capture structure once and reuse it safely everywhere.
The “Jungle Monkey” goal
Perhaps the most memorable concept in the talk was Patrik’s stated design goal:
He wanted Marmalade to feel like being a monkey in the jungle handed a smartphone — “How is this even possible?”
That sense of wonder — seeing powerful abstractions work, even when you wrote them — was the outcome he aimed for.
And in his words: he achieved it.
What’s next for Marmalade?
Marmalade is still evolving. Patrik wants to add more advanced features, including:
- floating point support (eventually)
- boolean conveniences (eventually)
- type classes
- bidirectional type checking (combining bottom-up inference with top-down checking)
The project is open source, actively developed in Rust, and Patrik welcomed contributions.
Takeaway
“Functional Marmalade” wasn’t just a talk about a language. It was a reminder of something deeper:
Functional programming isn’t only a style — it’s an entire way of thinking about programs as structured, checkable, composable systems.
And sometimes the best way to understand that structure is to build it yourself.