[Haskell-cafe] Errors in non-monadic code
Brandon Allbery
allbery.b at gmail.com
Mon Aug 19 20:26:48 CEST 2013
On Mon, Aug 19, 2013 at 2:09 PM, Brandon Allbery <allbery.b at gmail.com>wrote:
> 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.
Or possibly Valid and Invalid as the constructors....
This also means you can easily extend it later to include multiple errors,
or position information, or other annotations. You could also use it with
Monoid and/or the Writer monad to track success/failure in the most
appropriate way for your project, instead of being constrained to the
behavior of an existing instance.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130819/623840aa/attachment.htm>
More information about the Haskell-Cafe
mailing list