PROPOSAL: Export "readEither" from Text.Read

Hello, when writing simple String parsers, I find implementing this function over and over: readEither :: Read a => String -> Either String a I just found out that it is already defined in the module "Text.Read" in the "base" package but, sadly, it is not exported. Would there be any objections if: 1. I was to export it 2. I was to add another convenience function "readMaybe :: Read a => String -> Myabe a" defined in terms of "readEither". I can't think of any problems that this might cause and it would be very helpful to me and my colleagues. Discussion period: 2 weeks, so until 22 December 2011. -Iavor

On 9 December 2011 09:39, Iavor Diatchki
Hello,
when writing simple String parsers, I find implementing this function over and over:
readEither :: Read a => String -> Either String a
I just found out that it is already defined in the module "Text.Read" in the "base" package but, sadly, it is not exported. Would there be any objections if: 1. I was to export it 2. I was to add another convenience function "readMaybe :: Read a => String -> Myabe a" defined in terms of "readEither".
+1 to both. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Thu, 8 Dec 2011, Iavor Diatchki wrote:
when writing simple String parsers, I find implementing this function over and over:
readEither :: Read a => String -> Either String a
I think there was already discussion on it: http://www.haskell.org/pipermail/libraries/2008-February/009213.html

On 08/12/2011 22:39, Iavor Diatchki wrote:
Hello,
when writing simple String parsers, I find implementing this function over and over:
readEither :: Read a => String -> Either String a
I just found out that it is already defined in the module "Text.Read" in the "base" package but, sadly, it is not exported. Would there be any objections if: 1. I was to export it 2. I was to add another convenience function "readMaybe :: Read a => String -> Myabe a" defined in terms of "readEither".
I can't think of any problems that this might cause and it would be very helpful to me and my colleagues.
Discussion period: 2 weeks, so until 22 December 2011.
+1 Simon

very emphatic +1 for me. +1 for nubis bruno who works with me and I know supports this. max On Dec 12, 2011, at 5:52 PM, Simon Marlow wrote:
On 08/12/2011 22:39, Iavor Diatchki wrote:
Hello,
when writing simple String parsers, I find implementing this function over and over:
readEither :: Read a => String -> Either String a
I just found out that it is already defined in the module "Text.Read" in the "base" package but, sadly, it is not exported. Would there be any objections if: 1. I was to export it 2. I was to add another convenience function "readMaybe :: Read a => String -> Myabe a" defined in terms of "readEither".
I can't think of any problems that this might cause and it would be very helpful to me and my colleagues.
Discussion period: 2 weeks, so until 22 December 2011.
+1
Simon
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Thu, Dec 8, 2011 at 10:39 PM, Iavor Diatchki
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.

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
On Thu, Dec 8, 2011 at 10:39 PM, Iavor Diatchki
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@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Am 12.12.2011 16:24, schrieb Ben Millwood:
On Thu, Dec 8, 2011 at 10:39 PM, Iavor Diatchki
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.
http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.4.1.0/src/Text-... The current error messages are a bit stupid, anyway. An ambiguous parse could be avoided by (arbitrarily) returning the first match. Instead of "no parse" I would expect a proper char position of my error, but that's difficult to extract from the Read class.
Regardless, readMaybe is definitely a good idea, so +1 for that.
Indeed, readMaybe is a good idea and quite enough. C.

Hello,
today was the deadline for discussing this proposal and there were no
objections, so I'll go ahead and make the change.
-Iavor
On Thu, Dec 8, 2011 at 2:39 PM, Iavor Diatchki
Hello,
when writing simple String parsers, I find implementing this function over and over:
readEither :: Read a => String -> Either String a
I just found out that it is already defined in the module "Text.Read" in the "base" package but, sadly, it is not exported. Would there be any objections if: 1. I was to export it 2. I was to add another convenience function "readMaybe :: Read a => String -> Myabe a" defined in terms of "readEither".
I can't think of any problems that this might cause and it would be very helpful to me and my colleagues.
Discussion period: 2 weeks, so until 22 December 2011.
-Iavor
participants (9)
-
Ben Millwood
-
Christian Maeder
-
Daniel Peebles
-
Henning Thielemann
-
Iavor Diatchki
-
Ivan Lazar Miljenovic
-
Max Cantor
-
Simon Marlow
-
Yitzchak Gale