talira

transformers

Concrete functor and monad transformers for Haskell

open sourceBSD-3-Clausefree

transformers is the portable Haskell library of functor and monad transformers: the monad transformer class (Control.Monad.Trans.Class) and concrete transformers such as ReaderT, StateT, WriterT, ExceptT, MaybeT, ContT, RWST, AccumT and SelectT, each with operations and functions to lift operations from other transformers, plus functors like Compose, Product, Sum and Identity. Used on its own, operations are lifted through a transformer stack by hand; with the mtl or monads-tf class packages, they're lifted automatically. It's one of the most depended-on packages on Hackage, written by Andy Gill and Ross Paterson and maintained by Ross Paterson, Steven Shuck and Benjamin McRae.

Problems it solves

  • add state, a reader environment and error handling to Haskell code without passing them around by hand
  • stack a StateT over IO in my Haskell program
  • short-circuit a chain of Haskell IO actions on the first error with ExceptT
  • combine several monadic effects in a portable Haskell library without extra dependencies

Features

  • the MonadTrans class for lifting through transformer stacks
  • ReaderT, WriterT, StateT, ExceptT, MaybeT, ContT, RWST, AccumT, SelectT and IdentityT
  • lazy, strict and CPS variants of State, Writer and RWS
  • functor combinators: Compose, Product, Sum, Reverse, Constant, Backwards and Lift
  • portable Haskell with no dependencies beyond base
  • works with mtl or monads-tf for automatic lifting

Alternatives

The same job

These do what transformers does.

  1. mtl The Monad Transformer Library

Compare transformers with the top 3