Gist 0e59d1c2d63aaea35573
This example demonstrates benchmark-driven optimization of recursion schemes in Haskell, using the Criterion library’s `defaultMain`, `bgroup`, and `bench` functions to measure performance. The code defines catamorphisms (`ffold`), anamorphisms (`funfold`), hylomorphisms, and build functions (`fbuild`, `funbuild`), then applies them to natural numbers, lists, and trees. It highlights how `INLINE` pragmas and `RULES` for fusion (e.g., `ffold/fbuild`) improve execution speed, as shown in benchmarks like `lengthL`, `mapL`, and `depthT` over sample data structures.