PROPOSAL: Export "readEither" from Text.Read
pumpkingod at gmail.com
Mon Dec 12 18:46:08 CET 2011
Just parse the human-readable string with another parser, to get the
machine-readable error description ;) and don't forget to parse the error
your error string parser produces too.
+0.7 for proposal, but +1 if we have a nice error ADT :)
On Mon, Dec 12, 2011 at 10:24 AM, Ben Millwood <haskell at benmachine.co.uk>wrote:
> On Thu, Dec 8, 2011 at 10:39 PM, Iavor Diatchki
> <iavor.diatchki at gmail.com> wrote:
> > Hello,
> > when writing simple String parsers, I find implementing this function
> > over and over:
> > readEither :: Read a => String -> Either String a
> The only thing that bothers me about this is the fact that the error
> is a String; I don't think that's a very good type for errors, because
> only humans can really effectively interpret it. I don't know whether
> it's worth introducing a new sum type just for the different kinds of
> read error.
> Regardless, readMaybe is definitely a good idea, so +1 for that.
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries