Portability | non-portable (rank-2 polymorphism) |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | None |

"Free Monads for Less"

This is based on the "Free Monads for Less" series of articles:

http://comonad.com/reader/2011/free-monads-for-less/ http://comonad.com/reader/2011/free-monads-for-less-2/

# Documentation

The Church-encoded free monad for a functor `f`

.

It is *asymptotically* more efficient to use (`>>=`

) for `F`

than it is to (`>>=`

) with `Free`

.

MonadTrans F | |

MonadReader e m => MonadReader e (F m) | |

MonadState s m => MonadState s (F m) | |

MonadWriter w m => MonadWriter w (F m) | |

Functor f => MonadFree f (F f) | |

Monad (F f) | |

Functor (F f) | |

MonadPlus f => MonadPlus (F f) | |

Applicative (F f) | |

Alternative f => Alternative (F f) | |

MonadCont m => MonadCont (F m) | |

Apply (F f) | |

Bind (F f) |

improve :: Functor f => (forall m. MonadFree f m => m a) -> Free f aSource

Improve the asymptotic performance of code that builds a free monad with only binds and returns by using `F`

behind the scenes.

This is based on the "Free Monads for Less" series of articles by Edward Kmett:

http://comonad.com/reader/2011/free-monads-for-less/ http://comonad.com/reader/2011/free-monads-for-less-2/

and "Asymptotic Improvement of Computations over Free Monads" by Janis Voightländer: