haskell-pragmatic-core
Core conventions for pragmatic, production-quality Haskell. Use when writing Haskell code, designing data types, choosing language extensions, or evaluating whether a given approach is appropriately simple.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install pragmatic-haskell-haskell-pragmatic-coreManual setup by platform
Claude Code
~/.claude/skills/pragmatic-haskell-haskell-pragmatic-core/SKILL.md
Instructions
Pragmatic Haskell — Core Conventions
The Guiding Principle
Every design decision should pass this test: does the added complexity pay
for itself in concrete, measurable benefit?
This is not a call for the least possible Haskell — it is a call for
justified Haskell. A newtype wrapper for a domain primitive is justified
complexity. A five-layer effect system for a CRUD service is not.
Type Design
Use the type system to make invalid states unrepresentable, not to demonstrate
mastery of the type system.
Newtypes for domain primitives. Never pass raw Int, Text, or
ByteString where a domain type is appropriate.
Sum types for mutually exclusive states. A Bool parameter that switches
behaviour is a sum type waiting to be born. A String that encodes a
category is a sum type waiting to be born.
Smart constructors for invariants. If a type has constraints (e.g.
non-empty, positive, valid email), enforce them at construction time and make
the constructor private.
Strict fields by default. Constructor fields should carry ! unless
there is an explicit, documented reason for laziness.
DerivingStrategies always. Every deriving clause must specify stock,
newtype, or anyclass explicitly.
Always derive Show. Never define Show manually — the derived instance
is always useful for inspecting structure. Define Pretty (from
prettyprinter) for human-readable output when needed.
See references/type-design.md for worked examples.
Naming Conventions
Functions and variables: lowerCamelCase (fetchUser, parseConfig).
Types, typeclasses, constructors: UpperCamelCase (UserId, AppError).
Abbreviations: do not capitalise all letters. Write HttpServer not
HTTPServer. Exception: two-letter abbreviations (IO, DB).
Ticks: avoid ticks (') to distinguish function variants. Express the
difference in the name: runWithLogs not run'. Ticks convey no information
about what changed; the name should.
newtype unwrappers: prefix with un followed by the type name:
unUserId, unEmail, unAmount.
Smart constructors: prefix with mk: mkUserId, mkEmail.
Record fields: prefix with an abbreviated type name to avoid collision:
configHost, envDb, hrDate. This avoids DuplicateRecordFields churn.
Constructor punning: avoid using the same name for a type and its single
constructor. Prefer data Foo = MkFoo over data Foo = Foo. This makes it
easier to search for constructor uses vs type uses and avoids ambiguity with
TypeApplications. Exception: newtype wrappers, where the punned form is
so established it is the convention:
-- Exception: newtype — punning is fine here
newtype UserId = UserId { unUserId :: Int }
deriving stock (Eq, Ord, Show)
-- Rule: single-constructor data — avoid punning
data Colour = MkColour { colourR :: !Word8, colourG :: !Word8, colourB :: !Word8 }
deriving stock (Eq, Show)
Module names: use singular form (Data.Map, not Data.Maps).
Extension Policy
The project uses GHC2021 as the language edition baseline. Only
NoImplicitPrelude goes in default-extensions; all other extensions are
declared per-module.
Tier 1 — use freely (ergonomic, well-understood, low cognitive overhead):
OverloadedStrings, LambdaCase, MultiWayIf, TupleSections,
NamedFieldPuns, DerivingStrategies, GeneralizedNewtypeDeriving,
DeriveAnyClass, DerivingVia, NegativeLiterals, BangPatterns,
ScopedTypeVariables, OverloadedLists, ImportQualifiedPost,
BlockArguments.
Tier 2 — use with a justifying comment (more powerful, more cognitive
overhead; the comment must explain what bug this prevents that a simpler
approach would not):
TemplateHaskell, QuasiQuotes, TypeFamilies, GADTs, DataKinds,
FunctionalDependencies, ConstraintKinds, DefaultSignatures,
AllowAmbiguousTypes, UndecidableInstances.
Tier 3 — avoid; requires team discussion (rarely justified in production
code; known to cause surprising behaviour or poor error messages):
RebindableSyntax, ImpredicativeTypes, IncoherentInstances,
OverlappingInstances.
Never suppress safety warnings:
-Wno-incomplete-uni-patterns and -Wno-partial-fields are banned. Fix the
code.
See references/extensions.md for the full annotated list with rationale.
Monad Stack
Start simple. Introduce complexity only when the current approach is
demonstrably painful.
-
Plain
IOwith explicitEnv— the right choice for most new code.
Pass the environment record explicitly to functions that need it. -
ReaderT Env IO— introduce whenEnvthreading dominates more than
~5 function signatures. This is the ceiling for most services. -
ReaderT Env IO+ one more layer (e.g.ExceptT) — maximum for new
code. Document whyEitherin the return type is insufficient.
Never introduce a novel effect system unless the codebase already uses one.
Deep MTL stacks and algebraic effect libraries are Tier 2 decisions at
minimum.
Partial Functions
These are banned in production code paths:
| Banned | Safe alternative |
|---|---|
head, tail, last, init | Pattern match or NonEmpty |
fromJust | Pattern match, maybe, or fromMaybe with a default |
read | Text.Read.readMaybe |
!! | Map.lookup, Vector.!?, or explicit bounds check |
cycle [] | Guard against empty input |
error in reachable paths | Either / Maybe / throwIO |
Using error on a provably unreachable path is acceptable if:
- The enclosing function has a
HasCallStackconstraint. - There is a comment explaining why the path is impossible.
Text and IO
Data.Text(strict) for all human-readable text.Data.ByteString(strict) for binary data.Data.Text.IOfor file I/O.Prelude.readFileandPrelude.getContentsare banned (lazy IO).Stringis only acceptable at legacy interop boundaries; document why.
Anti-Patterns
The following patterns indicate unjustified complexity or common bugs. See
references/anti-patterns.md for before/after examples of each.
StringwhereTextshould be used- Partial functions on reachable paths
- Lazy IO (
Prelude.readFile,Prelude.getContents) Boolparameters that switch behaviourStringorIntto represent a state machine or category- Transformer stacks deeper than 3 layers
- Type classes with only one implementation
- Point-free chains that require mental eta-expansion
nubon anything but tiny lists- Missing strict fields (
!) in data type constructors - Premature abstraction over a single concrete use case
- Ticks in function names (
run'instead ofrunWithLogs) - Multi-line parenthesised expressions (extract to
wherebinding) foldlwithout'on a strict accumulatortypealias for safety wherenewtypeis needed
Further Reading
- Matt Parsons, "Write Junior Code" (2019) — on accessibility in production code
- Michael Snoyman, "Boring Haskell Manifesto" (2019) — on power-to-weight ratio
- Kowainik Haskell Style Guide — comprehensive commercial Haskell conventions
- Tibbe's Haskell Style Guide — practical formatting and naming conventions
- Plutus Haskell Style Guide — production Haskell in a large open-source project
Security
Reviews (0)
More from Pragmatic Haskell
View source →More Build skills
Browse category →Frequently asked questions about haskell-pragmatic-core
What does the haskell-pragmatic-core skill do?
Core conventions for pragmatic, production-quality Haskell. Use when writing Haskell code, designing data types, choosing language extensions, or evaluating whether a given approach is appropriately simple. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the haskell-pragmatic-core skill?
Run `npx @skills-hub-ai/cli install pragmatic-haskell-haskell-pragmatic-core` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/pragmatic-haskell-haskell-pragmatic-core/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does haskell-pragmatic-core work with?
haskell-pragmatic-core runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the haskell-pragmatic-core skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use haskell-pragmatic-core after installing it?
In Claude Code, type `/pragmatic-haskell-haskell-pragmatic-core` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the haskell-pragmatic-core skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.