Time Travelling and Fixing Bugs with Property-Based Testing (2019)

From “time‑travel” tests to vampire signups: devs brawl over how to catch sneaky bugs

TLDR: A Haskell tutorial shows how property-based testing can uncover hidden signup bugs by auto-generating inputs. The crowd split: fans say it’s a bug-finding superpower, skeptics call it overkill and too random, and everyone memed the 150‑year age rule—highlighting a real debate on smarter, earlier bug detection.

A resurfaced 2019 Haskell tutorial about property‑based testing—where you describe rules and let the computer auto‑generate tons of inputs to break your app—sent the comments into full soap‑opera mode. The demo? A user signup checker that bans under‑18s and, hilariously, caps age at 150. Cue memes about vampires, time travelers, and QA with a DeLorean. Fans cheered: “Let the machine find the weird stuff we’d never think of!” They loved how the validation shows all mistakes at once instead of failing on the first one, and praised Hedgehog for stress‑testing edge cases. Skeptics clapped back: “Overkill for a simple form—write normal tests.” They also grumbled about randomness, insisting tests must be predictable. Then it got spicy: Hedgehog vs QuickCheck (two Haskell test tools) became a mini‑religious war, and debates raged over how many examples to run—100 or 10,000? Meanwhile, practical devs asked why a signup form lives in Haskell at all, with one joker claiming “150 is elves‑only.” Supporters replied that catching subtle bugs early saves real money. The tutorial’s core idea—test the generator itself and refactor to handle non‑determinism—had the “anti‑flaky test” crowd nodding, while the “fail fast” crew begged for simplicity. Also linked: the Validation package for piling up errors with receipts.

Key Points

  • The tutorial demonstrates property-based testing in Haskell using Hedgehog on a user signup validation system.
  • Validation rules include a valid username and age constraints between 18 and 150 years.
  • The Validation type accumulates errors via Applicative, unlike Either, and uses a NonEmpty list for failures.
  • Data structures include SignupForm (Text name, Int age), Signup (Text name, Natural age), and SignupError (NameTooShort, NameTooLong, InvalidAge).
  • A positive property test (prop_valid_signup_form_succeeds) generates valid inputs and asserts validateSignup always succeeds; the tutorial also covers refactoring, non-determinism, generator testing, test counts, and test-implementation coupling.

Hottest takes

“If your tests aren’t deterministic, you’re just rolling dice with production” — SkepticStack
“Property‑based testing turned my bug‑hunt into a cheat code” — bughunter42
“Nobody is 150 unless you’re a vampire or a PM trying to extend the deadline” — CoffeeVamp
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.