Making Risk Decisions with Haskell at Scale
summary
Mercury converts entangled DB-driven rules into pure Haskell policy functions by representing policy inputs as gadget sum inputs and compiling environments as suspended query closures; this lets policies be run purely, property-tested, and audited while the actual SQL executes only when a caller forces a suspended field. The system uses an at-most-once evaluator based on ST to avoid IO leakage, reduces load on a 13,000+ module monolith, improves shrinking in QuickCheck, and is already deployed and reused outside risk.
AI-written summary · about
chapters (8)
- 0:00Introduction & Mercury background
- 1:40Compliance challenges in FinTech
- 4:30Translating policies into Haskell code
- 10:15Dealing with entangled systems
- 17:45Enabling auditing and property-based testing
- 27:20Design goals of a policy engine
- 36:00Building small, pure, testable packages
- 47:00Q&A and reflections








