<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<span id="mailbox-conversation"><div>The “purely applicative Either” is Either with a new Applicative interface which can no longer take a corresponding Monad interface. I have personally reinvented it over and over although it is perhaps commonly known as Validation:</div>
<div><br></div>
<div> data Validation e a = Invalid e | Valid a deriving ( Show, Functor, … )</div>
<div><br></div>
<div>
<div> instance Monoid e => Applicative (Validation e) where</div>
<div> pure = Valid</div>
<div> Invalid e1 <*> Invalid e2 = Invalid (e1 <> e2)</div>
<div> Invalid e1 <*> _ = Invalid e1</div>
<div> <*> Invalid e2 = Invalid e2</div>
<div id="mb-reply"> Valid f <*> Valid a = Valid (f a)</div>
<div id="mb-reply"><br></div>
<div id="mb-reply"> -- No corresponding Monad</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">It could be perhaps better implemented as a newtype wrapper over Either to facilitate rapid conversion to the more common type.</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">Validation appears in its own package developed by Tony Morris and Nick Partridge. It also exists in Jonathan Sterling’s Vinyl package under the name Data.Vinyl.Idiom.Validation.Result. Gabriel Gonzalez has also told me that he’d be happy to add it to his `errors` package if a PR was made.</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">The common use for Validation is to traverse over a structure and accumulate errors throughout it. In other words, failures should not halt the process and we can think of each operation as occurring in parallel.</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">Not only is Validation a good example of an “Applicative without a Monad” its also a very useful practical type.</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">I would like to build a proposal to include Validation in some form in a common package. Despite the misalignment with the name, `transformers` seems like a plausible target, though I fear changes to that package are rarely worth the pain. Suggestions on implementation and target package are welcome. Pending informative feedback, I will try to write a true proposal within 2 weeks.</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">Thanks everyone,</div>
<div id="mb-reply"><br></div>
<div id="mb-reply">Joseph</div>
</div></span><div class="mailbox_signature">
<br>Joseph</div>
</body></html>