The Haskell Symposium is a two-day workshop co-located with the International Conference on Functional Programming (ICFP). In a previous blog post we discussed the Haskell Implementors’ Workshop (HIW), which is another Haskell-workshop co-located with ICFP, but unlike HIW, the Haskell Symposium is a scientific workshop with peer-reviewed papers.
This year Well-Typed presented one paper at the Haskell Symposium: Edsko de Vries presented the theory that underlies his new library for property based testing, called falsify. You can watch the presentation online:
Haskell ’23: falsify: internal shrinking reimagined for Haskell
The “reimagined” in the title refers to the fact that falsify
was inspired by
the Python library Hypothesis. The presentation
focuses on how falsify
works rather than how it is different from Hypothesis;
section 7 of the paper on
falsify
discusses the differences in
detail; you can access the paper without a
paywall on Edsko’s website. Alternatively,
the blog post falsify: Hypothesis-inspired shrinking for
Haskell gives an overview of the theory though in less
depth than the paper does, and also also includes a tutorial on how to use the
library.
Both the paper and the blog post also discuss how falsify
differs from both
QuickCheck as well as
hedgehog, but the TL;DR is that
in QuickCheck
you need to write both a generator and a shrinker separately
whereas in both hedgehog
and falsify
the generator implies the shrinker;
however, unlike in hedgehog
, the implied shrinker in falsify
works well even
when monadic bind (>>=
or do
-notation) is used.
Hypothesis-style internal shrinking has been receiving some interest from the academic community recently, especially from the team of Benjamin Pierce at UPenn: previously Goldstein and Pierce presented Parsing Randomness at OOPSLA, and this year Goldstein et al. presented Reflection on Random Generation at ICFP. The presentation is worth watching: they present a way to derive parsers (a.k.a. generators) from existing counter-examples, and then use internal shrinking to shrink those counter-examples.
The full list of ICFP presentations as well as the full list of Haskell Symposium presentations are both available from the ACM SIGPLAN YouTube channel.