ekmett / free

free monads
http://hackage.haskell.org/package/free
Other
161 stars 65 forks source link

Free MonadPlus and (another variant of) Alternative #141

Open nponeccop opened 8 years ago

nponeccop commented 8 years ago

There is From monoids to near-semirings: the essence of MonadPlus and Alternative article worth including in free.

ElvishJerricco commented 8 years ago

Your link is broken, but here's a working one.

Zemyla commented 4 years ago

I remember that, when I mathed it out and undid the innate right bias of the list based form, the Church style Free MonadPlus wound up being:

newtype FMP f a = FMP { runFMP :: forall r. Monoid r => (a -> r) -> (f r -> r) -> r }

In retrospect, it's just the crossbreed between FM and FreeMonoid, and the instances are all obvious.