Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
The Plus monad - a free combination of monads. This is very similar to coproducts, but not quite the same.
Coproducts are due to Luth and Ghani, "Composing Monads Using Coproducts," http://www.informatik.uni-bremen.de/~cxl/papers/icfp02.pdf
- newtype (m ::+ n) t = Plus {}
- inl :: m t -> (::+) m n t
- inr :: n t -> (::+) m n t
- mapPlus :: (forall t. m t -> m1 t) -> (forall t. n t -> n1 t) -> (m ::+ n) t -> (m1 ::+ n1) t
- comm :: (m ::+ n) t -> (n ::+ m) t
- assoc :: (::+) ((::+) m n) n1 t -> (::+) m ((::+) n n1) t
- assoc1 :: (::+) t ((::+) n1 n) t1 -> (::+) ((::+) t n1) n t1
- cancelLeft :: MonadPlus t => (::+) Identity t t1 -> t t1
- cancelRight :: MonadPlus t => (::+) t Identity t1 -> t t1
- refl :: MonadPlus t => (::+) t t t1 -> t t1
- distr :: (::+) (Product m1 h) (Product n1 h1) a -> Product ((::+) m1 n1) ((::+) h h1) a