Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Haskell Design Patterns

Design patterns in Haskell

This is a list of patterns. I'm collecting this list with an idea to write a book similar to the GoF book.

My patterns:

  • Typed / Untyped pattern
  • Typed Avatar pattern (see Hydra and Node)
    • Typed Options pattern (see EulerHS)
  • Control Structure pattern (see CLI control structure in Hydra and similar in Node)
  • Declarative Protocol pattern (see CLI in Hydra & Node, TCP / UDP / JSON RPC in Node)
  • Record / Replay approach (see automatic whitebox testing and similar in Cirkit)
  • Interface / Runtime / Interpreter / Business Logic
  • Connectionless script (see KV DB & SQL DB in Hydra)
  • Poor man's dependent types with parsers

IoC & DI patterns / approaches:

  • ReaderT pattern
  • Service Handle pattern
  • mtl / Final Tagless
  • Approach from the Eric Torreborre's talk (from
  • Hierarchical Free Monads
  • Extensible effect systems

Other patterns:

  • The Has Type Class pattern
  • Higher-Kinded Data
  • MVar Request-Response pattern
  • Abstract Interpreter pattern
  • Global state with IORef and unsafePerfomIO
  • Transactional monadic context (see STM, ST, hedis, SQL DB in Hydra)
  • WithResource pattern (bracket)
  • See also: Haskell mini-patterns

Architecture patterns:

  • Functional Core, Imperative Shell
  • Onion Architecture
  • 3-layer cake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment