Lazy Evaluation
summary
Three hours of worked examples show how Haskell’s lazy, outermost reduction (weak head normal form) really behaves: null on an enum is constant space, selfEqual forces linear time but not residency, map stays incremental while reverse builds the whole spine, and naive length leaks until an accumulator gets a bang pattern. Measurement uses GHC -s stats and ghci sprint/print; collected numbers show small overheads and a maximum residency 44k baseline. Partitioning into two lists and the Writer pattern are shown to be inherently leaky; GHC’s demand analyzer helps but cannot be fully trusted.
AI-written summary · about
chapters (18)
- 0:00Lazy evaluation intro
- 1:04Well-Typed Haskell consultancy
- 3:35Speaker background
- 8:56What is lazy evaluation
- 14:15First example: null function
- 36:23Demand propagation and WHNF
- 51:07Strictness in Haskell
- 1:04:44Break announcement
- 1:05:26Second example: null via equality
- 1:12:11Third example: self-equality and sharing
- 1:33:16Sharing and CAFs in Haskell
- 1:40:32Debugging with sPrint and print in GHCi
- 1:53:40Fourth example: map reverse with null
- 2:00:05Fifth example: null via length
- 2:10:58Bang patterns and strict accumulators
- 2:23:17Demand analyzer and optimizations
- 2:28:01Final example: partition and space leaks
- 2:34:42Conclusion and Q&A
related talks
36mWorking Hard to Keep Things Lazy
53mIntro to Haskell for Erlangers
58mLet’s Get Lazy—The Real Power of Functional Programming
01h 04mHaskell - A Peek Inside the Ivory Tower
45mFunctional Programming bits and pieces
27mHaskell equations, thirty-eight years later
28mLightweight Testing of Persistent Amortized Time Complexity in the Credit Monad
24mCatching space leaks at compile-time using th-deepstrict
