<div dir="ltr">On Mon, Aug 19, 2013 at 1:48 PM,  <span dir="ltr">&lt;<a href="mailto:jabolopes@google.com" target="_blank">jabolopes@google.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What is the proper way to implement a non-monadic function that checks<br>
whether a given value is correct and gives a proper error message<br>
otherwise ? What is the recommended option ?<br>
<br>
* Either String a<br></blockquote><div><br></div><div>Preferred, usually, since Nothing is regarded as an error condition of sorts: the Monad instance for Maybe associates Nothing with `fail`, which is invoked on failed pattern matches; likewise it&#39;s mzero for MonadPlus and mempty for Monoid, both of which use it (differently) to reflect certain &quot;failure&quot; scenarios).</div>
<div><br></div><div>If nothing else, it would be highly confusing to see Nothing associated with success given its widespread association with failure.</div><div><br></div><div>Alternatively, have you considered using your own ADT? `data Validity = Success | Failure String` would give you more readable / comprehensible code without needing to worry about assumptions or common usage.</div>
</div><div><br></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>