# Research papers/Functional pearls

From HaskellWiki

Functional pearls are elegant, instructive examples of functional programming. They are supposed to be fun, and they teach important programming techniques and fundamental design principles. They traditionally appear in The Journal of Functional Programming and and at ICFP and affiliated workshops.

## History

The history of functional pearls is covered by:

- How to Write a Functional Pearl
- Richard Bird. ICFP 2006.

- Fifteen years of functional pearls
- Richard Bird. ICFP 2006.

- Strachey's functional pearl and forty years on
- Mike Spivey. 2006.

- On Barron and Strachey's Cartesian Product Function
- Olivier Danvy and Michael Spivey. July 2007

There have been many functional pearls in JFP and and some others at ICFP and the Haskell Workshop. There is also a collection of them in The Fun of Programming.

The pearls tend to concentrate on:

- Examples of program calculation and proof
- Neat presentations of new or old data structures
- Interesting applications and techniques

Some advice on writing pearls for JFP is available in this editorial.

## Online

Functional pearls available online.

- 2021

- It’s Easy As 1,2,3 - Graham Hutton.

- 2018

- What You Needa Know about Yoneda: Profunctor Optics and the Yoneda Lemma - Guillaume Boisseau and Jeremy Gibbons.

- 2017

- A Pretty But Not Greedy Printer - Jean-Philippe Bernardy.
- Algebraic Graphs with Class - Andrey Mokhov.
- Ode on a Random Urn - Leonidas Lampropoulos, Antal Spector-Zabusky and Kenneth Foner.

- 2016

- Deriving a Probability Density Calculator - Wazim Mohammed Ismail and Chung-chieh Shan.
- Queueing and Glueing for Optimal Partitioning - Shin-Cheng Mu, Yu-Hsi Chiang and Yu-Han Lyu.
- Free Delivery - Jeremy Gibbons.
- All Sorts of Permutations - Jan Christiansen, Nikita Danilenko and Sandra Dylus.

- 2015

- A Smart View on Datatypes - Mauro Jaskelioff and Exequiel Rivas.
- Two Can Keep a Secret and If One of Them Uses Haskell - Alejandro Russo.

- 2013.

- Solving the Snake Cube Puzzle in Haskell - Mark P. Jones.

- 2012

- When Maybe is not good enough - Michael Spivey.
- Monoids: Theme and Variations - Brent Yorgey.

- 2011

- The Hough transform - Maarten Fokkinga.
- Sorted. Verifying the Problem of the Dutch National Flag in Agda - Wouter Swierstra.
- Typed Quote/Antiquote - Or: Compile-time Parsing - Ralf Hinze.

- 2010

- Every Bit Counts - Dimitrios Vytiniotis and Andrew Kennedy.
- A Play on Regular Expressions - Sebastian Fischer. Frank Huch and Thomas Wilke.

- 2009

- Free Theorems Involving Type Constructor Classes - Janis Voigtländer.
- Linear, Bounded and Functional Pretty-Printing - S. Doaitse Swierstra and Olaf Chitil.
- Bidirectionalization for Free! - Janis Voigtländer.
- A Domain-Specific Language for Experimental Game Theory - Eric Walkingshaw and Martin Erwig.

- 2008

- Functional Pearl: Data Types A La Carte - Wouter Swierstra.
- Functional Pearl: Streams and Unique Fixed Points - Ralf Hinze.
- Generic Discrimination: Sorting and Partitioning Unshared Data in Linear Time - Fritz Henglein.
- Undoing Dynamic Typing - Nick Benton.
- Much Ado about Two: A Pearl on Parallel Prefix Computation - Janis Voigtländer.
- Clowns to the Left of me and Jokers to the Right: Dissecting Data Structures: Conor McBride.

- 2007

- Functional Pearl: The Great Escape: Or how to jump the border without getting caught - David Herman.
- Scrap Your Zippers
- Michael Adams. (superseded by the WGP 2010 version.)

- 2006

- A type-correct, stack-safe and provably correct expression compiler in Epigram - James McKinna and Joel Wright.
- Applicative Programming with Effects - Conor McBride and Ross Paterson.
- Enumerating the rationals - Jeremy Gibbons, David Lester and Richard Bird.
- A program to solve Sudoku
- Richard Bird. (slides; an implementation in Literate Haskell by Graham Hutton.)

- Probabilistic functional programming in Haskell - Martin Erwig and Steve Kollmansberger.
- Marble mingling - Sharon Curtis.
- Strong Types for Relational Databases - Alexandra Silva and Joost Visser.
- Finding celebrities: A lesson in functional programming - Richard Bird and Sharon Curtis.

- 2005

- Backtracking, interleaving and and terminating monad transformers - Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman and Amr Sabry.
- Scrap your Nameplate - James Cheney.

- 2004

- Pickler Combinators - Andrew Kennedy.
- Composing fractals - Mark P. Jones.
- Enumerating the strings of regular languages - M. Douglas McIlroy.
- Calculating the Sieve of Eratosthenes - Lambert Meertens. (slides.)

- Functional satisfaction - Luc Maranget. (more info.)

- Implicit configurations--or and type classes reflect the values of types - Oleg Kiselyov and Chung-chieh Shan.
- Global variables in Haskell - John Hughes.
- I am not a number -- I am a free variable - Conor McBride and James McKinna.
- Inverting the Burrows Wheeler transform - Richard Bird and Shin-Cheng Mu. (also here.)

- Parsing permutation phrases - Arthur Baars and Andres Loh and S. Doaitse Swierstra.
- Concurrent distinct choices - Sergio Antoy and Michael Hanus.
- Functional chart parsing of context-free grammars - Peter Ljunglf.
- Type-Safe Cast - Stephanie Weirich.
- Parallel Parsing Processes - Koen Claessen.
- Derivation of a logarithmic time carry lookahead addition circuit - John O'Donnell and Gudula Runger.
- Linear lambda calculus and PTIME-completeness - Harry G. Mairson.
- On tiling a chessboard - Richard Bird.

- 2003

- Producing all ideals of a forest and functionally - Jean-Christophe Filliatre and Francois Pottier.
- Trouble shared is trouble halved - Richard Bird and Ralf Hinze.
- Formatting: a class act - Ralf Hinze.

- 2002

- A fresh look at binary search trees - Ralf Hinze.
- The countdown problem - Graham Hutton.
- Packrat parsing: simple, powerful, lazy, linear time and functional pearl - Bryan Ford.
- Monads for Incremental Computing - Magnus Carlsson.

- 2001

- Haskell does it with class: Functorial unparsing - Ralf Hinze.
- Unfolding pointer algorithms - Richard Bird.
- Maximum marking problems - Richard Bird.
- Weaving a web - Ralf Hinze and Johan Jeuring.
- Normalization by evaluation with typed abstract syntax - Olivier Danvy, Morten Rhiger and Kristoffer H. Rose.
- Do we need dependent types? - Daniel Fridlender and Mia Indrika.
- Red-black trees with types - Stefan Kahrs. (code.)

- 2000

- Perfect trees and bit-reversal permutations and a revision of Technical Report IAI-TR-99-4 - Ralf Hinze.
- Combinators for breadth-first search - Michael Spivey.
- Breadth-First Numbering: Lessons from a Small Exercise in Algorithm Design - Chris Okasaki.
- Deriving Backtracking Monad Transformers - Ralf Hinze.
- Recursive subtyping revealed - Vladimir Gapeyev, Michael Y. Levin and Benjamin C. Pierce.
- Composing contracts: an adventure in financial engineering - Simon Peyton Jones, Jean-Marc Eber and Julian Seward.

- 1999

- A poor man's concurrency monad - Koen Claessen.
- Explaining binomial heaps - Ralf Hinze.
- Power series and power serious - M. Douglas McIlroy.
- Red-black trees in a functional setting - Chris Okasaki.
- Proof-directed debugging
- Robert Harper. (see also Proof-directed debugging: revisited for a first-order version.)

- A pointless derivation of radix sort - Jeremy Gibbons.

- 1998

- Monadic parsing in Haskell - Graham Hutton and Erik Meijer.
- Polytypic unification - Patrik Jansson and Johan Jeuring.
- Diets for fat sets - Martin Erwig.
- Even higher-order functions for parsing or Why would anyone ever want to use a sixth-order function? - Chris Okasaki.
- Meertens number - Richard Bird.

- 1997

- On merging and selection
- Richard Bird. (see also More on Merging and Selection.)

- On building trees with minimum height - Richard Bird.
- The Zipper
- Gerard Huet. (see also The Haskell Wikibook).

- Lazy wheel sieves and spirals of primes - Colin Runciman.
- Three algorithms on Braun trees - Chris Okasaki.

- 1996

- The Third Homomorphism Theorem - Jeremy Gibbons.
- Back to Basics: Deriving Representation Changers Functionally - Graham Hutton and Erik Meijer.
- Drawing Trees - Andrew J. Kennedy.
- Deriving Tidy Drawings of Trees
- Jeremy Gibbons. (see also the research report.)

- 1994

- On generating unique names - Lennart Augustsson, Mikael Rittri and Dan Synek.

- 1993

- Efficient Sets - A Balancing Act
- Stephen Adams. (
`Data.Set`

code.)

- Stephen Adams. (

- The Last Tail - Richard Bird.

- 1992

- A Symmetric Set of Efficient List Operations
- Rob R. Hoogerwoord. (Hoogerwoord's homepage.)

- Two Greedy Algorithms - Richard Bird.

- 1991

- On Removing Duplicates - Richard Bird.

- 1988

- Nondeterminism with Referential Transparency in Functional Programming Languages - F. Warren Burton.

## Potential pearls

Unpublished pearls.

- α-conversion is easy
- Thorsten Altenkirch. (unpublished draft.)