The modern indexed monad stack
Stacked is an indexed monad (see e.g. this description by Conor McBride) library built from the ground up to use modern GHC features (such as qualified do and quantified constraints).
For instance
- The monad hierarchy follows that of base with for instance
Applicative
andMonad
. These don't use distinctive namesIxApplicative
,IxMonad
, orixBind
: they use the standardApplicative
,Monad
, and(>>=)
names from base, and are meant to be imported qualified, and typically use with the qualified do notation. - But there is no indexed functor class defined in this library because, thanks
to quantified constraints, the standard functor class suffices. The functor
super-class for indexed applicative looks like
(forall i j. Functor f i j) => …
- We also take the opportunity of growing the stack from scratch to define a
single
Additive
class to replaceAlternative
andMonadPlus
. We then defineAlternative
asWhich uses both quantified constraints and impredicative types.type Alternative m = (Applicative m, forall r r' a. Additive (m r r' a))
The library is meant to feel familiar to Haskell programmers, despite the clean-ups that modern Haskell affords.
- Stacked has a rich sublibrary on continuation indexed monads and their relation with delimited control. This part of the library was developed to serve the needs of the Pup library.