Skip to main content

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.

v1.0.0New

Unsigned, install at your own risk

Unverified

This 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-core
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/pragmatic-haskell-haskell-pragmatic-core/SKILL.md

Setup guide →
0Save

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.

  1. Plain IO with explicit Env — the right choice for most new code.
    Pass the environment record explicitly to functions that need it.

  2. ReaderT Env IO — introduce when Env threading dominates more than
    ~5 function signatures. This is the ceiling for most services.

  3. ReaderT Env IO + one more layer (e.g. ExceptT) — maximum for new
    code. Document why Either in 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:

BannedSafe alternative
head, tail, last, initPattern match or NonEmpty
fromJustPattern match, maybe, or fromMaybe with a default
readText.Read.readMaybe
!!Map.lookup, Vector.!?, or explicit bounds check
cycle []Guard against empty input
error in reachable pathsEither / Maybe / throwIO

Using error on a provably unreachable path is acceptable if:

  • The enclosing function has a HasCallStack constraint.
  • 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.IO for file I/O.
  • Prelude.readFile and Prelude.getContents are banned (lazy IO).
  • String is 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.

  1. String where Text should be used
  2. Partial functions on reachable paths
  3. Lazy IO (Prelude.readFile, Prelude.getContents)
  4. Bool parameters that switch behaviour
  5. String or Int to represent a state machine or category
  6. Transformer stacks deeper than 3 layers
  7. Type classes with only one implementation
  8. Point-free chains that require mental eta-expansion
  9. nub on anything but tiny lists
  10. Missing strict fields (!) in data type constructors
  11. Premature abstraction over a single concrete use case
  12. Ticks in function names (run' instead of runWithLogs)
  13. Multi-line parenthesised expressions (extract to where binding)
  14. foldl without ' on a strict accumulator
  15. type alias for safety where newtype is 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
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from Pragmatic Haskell

View source →

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.635 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.535 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.346 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installs

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.