practical-haskell

Diagnose Haskell performance and strictness issues using GHC profiling and Core inspection.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/kaynetik/skills --skill practical-haskell
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: practical-haskell
Source: https://github.com/kaynetik/skills/tree/main/practical-haskell
Command: npx skills add https://github.com/kaynetik/skills --skill practical-haskell

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps diagnose and remediate Haskell performance, memory, and evaluation-order issues by aligning code with GHC optimization behavior and profiling evidence. It is focused on eliminating space leaks, improving strictness where appropriate, enabling fusion-friendly pipelines, and guiding pragmatic use of pragmas and newtypes.

Core Features & Use Cases

  • Profiling-guided fixes: Interpret profiler output and eventlog hints to locate allocation or time hotspots.
  • Strictness & memory: Recommend strict fields, bang patterns, foldl' usage, and UNPACK to avoid thunk buildup and indirection.
  • Specialization & inlining: Advise on INLINE/INLINABLE/SPECIALIZE pragmas and worker/wrapper transformations when Core shows dictionary or allocation overhead.
  • Core inspection: Tell developers what to look for in simplified Core (-ddump-simpl) and how it validates optimizations.
  • Use Case: Review a slow Haskell function, run profiling and Core dumps, and receive prioritized changes to reduce allocations and improve throughput.

Quick Start

Analyze the provided Haskell module using GHC profiling and simplified Core output and recommend concrete strictness, fusion, and specialization changes to reduce allocations and improve performance.

Frequently Asked Questions about practical-haskell

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix a space leak in Haskell caused by thunk buildup?

To fix a Haskell space leak from thunk buildup, apply strict fields, bang patterns, and foldl' to force evaluation and prevent deferred thunks from accumulating in memory.

How do I read GHC simplified Core to verify performance optimizations?

Reading GHC simplified Core from -ddump-simpl output involves inspecting the optimized intermediate code to confirm that strictness analysis, worker/wrapper transformations, and fusion have successfully eliminated allocation overhead.

What is the best way to reduce Haskell allocations during profiling?

The best way to reduce Haskell allocations during profiling is to interpret profiler output to locate hotspots, then apply UNPACK pragmas and fusion-friendly pipelines to minimize intermediate data structures.

When should I use INLINE or SPECIALIZE pragmas in GHC?

Use INLINE, INLINABLE, or SPECIALIZE pragmas in GHC when Core inspection shows dictionary or allocation overhead, enabling worker/wrapper transformations to eliminate typeclass indirection and improve throughput.

Does GHC fusion optimization work with strict fold pipelines?

GHC fusion optimization works with strict fold pipelines when using foldl' and appropriate strictness annotations, allowing list operations to be optimized away while preventing space leaks from deferred evaluation.

Why does my Haskell program have high memory usage despite profiling?

High Haskell memory usage despite profiling often indicates hidden space leaks from lazy evaluation, requiring strictness analysis, strict data fields, and foldl' usage to eliminate thunk accumulation and reduce heap footprint.