free icon indicating copy to clipboard operation
free copied to clipboard

Free MonadPlus and (another variant of) Alternative

Open nponeccop opened this issue 8 years ago • 2 comments

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

nponeccop avatar Nov 04 '16 19:11 nponeccop

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

ElvishJerricco avatar Nov 05 '16 22:11 ElvishJerricco

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.

Zemyla avatar Dec 23 '19 14:12 Zemyla