Diagnosing and Fixing Space Leaks in Haskell Applications
Learn how to identify and resolve space leaks in Haskell by diagnosing thunk build-up using GHC profiling tools and applying strictness annotations.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to identify and resolve space leaks in Haskell by diagnosing thunk build-up using GHC profiling tools and applying strictness annotations.
GHC's DerivingVia extension lets you attach typeclass instances by delegating to existing instances — no newtype wrappers, zero runtime cost. A practical walkthrough with Age/Sum Int, chaining strategies, and Core verification.
STM replaces lock-based synchronization with composable atomic blocks that retry on conflict, eliminating deadlocks and providing automatic rollback. This note covers GHC 8.10–9.8 runtime behavior, trust boundaries, operational checks, failure modes, and when to choose alternatives.
GHC's DerivingVia extension (since 8.6) lets you compose typeclass instances without boilerplate newtype wrappers. A practical walkthrough with JSON encoding example, role restrictions, and a verification checklist.
Learn how to balance Haskell's lazy evaluation with strictness annotations to prevent space leaks and implement efficient infinite data structures.
GHC LinearTypes lets the type checker enforce single-use resource handling at compile time, with no runtime overhead.
Haskell's default laziness stores data fields as thunks. Making data types strict by default with StrictData prevents space leaks from thunk buildup, while selective laziness preserves composability where it matters.
Long-running Haskell services often leak memory through thunk accumulation, not retained data. GHC's StrictData pragma flips record fields to strict-by-default—here's how to apply it safely and verify it with heap profiles.
Learn how to use Haskell's STM primitives to safely update a shared counter from multiple threads, compile with GHC, run with threading enabled, and verify the result.