- Home
- Skills
- Copyleftdev
- Sk1llz
- Peyton Jones
peyton-jones_skill
- Python
3
GitHub Stars
1
Bundled Files
3 weeks ago
Catalog Refreshed
2 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstart where the catalogue uses aiagentskills.
npx veilstart add skill copyleftdev/sk1llz --skill peyton-jones- SKILL.md6.8 KB
Overview
This skill encodes Simon Peyton Jones’s practical Haskell style for writing compiler-friendly, performant functional code. It emphasizes principled laziness, strategic strictness, and patterns that let GHC optimize aggressively. Use it to produce Haskell that is easy to reason about, profiles well, and runs efficiently in real-world systems.
How this skill works
The skill inspects code patterns and rewrites or suggests changes to follow SPJ’s design principles: prefer laziness by default but add strictness where it matters, use newtypes and UNPACK for zero-cost abstractions, and structure pipelines for fusion. It highlights opportunities for INLINE/INLINABLE, SPECIALIZE pragmas, and worker/wrapper transformations, and advises checking GHC Core and profiling output. The result is small, composable functions that the compiler can transform safely.
When to use it
- When implementing performance-sensitive Haskell libraries or hot loops
- When diagnosing space leaks or unexpected thunk buildup
- When you want code that GHC can fuse and specialize automatically
- When designing APIs that need zero-cost abstractions and type safety
- Before micro-optimizing: to get compiler-friendly structure first
Best practices
- Prefer lazy evaluation for APIs, add bang patterns or strict fields for accumulators
- Use foldr/foldl' and fusion-friendly combinators (map, filter, concatMap) in pipelines
- Profile first, then inspect -ddump-simpl Core to verify fusion and inlining
- Use newtype and UNPACK pragmas for zero-cost wrappers and to remove indirection
- Mark hot polymorphic functions INLINE/INLINABLE and add SPECIALIZE for common types
Example use cases
- Rewriting a list-processing pipeline to enable GHC fusion and remove intermediate allocations
- Converting a naive recursive algorithm into a tail-recursive worker/wrapper with strict accumulator
- Adding UNPACK and strict fields to a hot data structure to eliminate pointer overhead
- Specializing a polymorphic numeric routine with SPECIALIZE pragmas for Int/Double performance
- Diagnosing and fixing space leaks caused by lazy left folds by switching to foldl'
FAQ
Use strict fields for accumulators and hot data where thunks cause space/time overhead; keep laziness at the API boundary when it improves composability.
How do I know if fusion actually happened?
Profile for allocations and compile with -O2 -ddump-simpl to inspect Core; fused pipelines appear as a single recursive function with fewer lets and no intermediate list constructions.