|Maintainer||Edward Kmett <firstname.lastname@example.org>|
left-distributive MonadPlus for free.
- class Monad m => MonadFree f m | m -> f where
- wrap :: f (m a) -> m a
- data Free f a
- retract :: MonadPlus f => Free f a -> f a
- liftF :: Functor f => f a -> Free f a
- iter :: Functor f => (f a -> a) -> ([a] -> a) -> Free f a -> a
- hoistFree :: Functor g => (forall a. f a -> g a) -> Free f b -> Free g b
Monad is one that does no work during the normalization step beyond simply grafting the two monadic values together.
On the other hand, consider:
data Tree a = Bin (Tree a) (Tree a) | Tip a
data Pair a = Pair a a
And we could make an instance of
MonadFree for it directly:
We model this internally as if left-distribution holds.