[Haskell-cafe] Proposal: Rational read

Sean Leather sean.leather at gmail.com
Sun Aug 14 21:28:14 UTC 2016


Hi Erik,

On Sun, Aug 14, 2016 at 11:01 PM, Erik Hesselink wrote:

> On 14 August 2016 at 16:00, Sean Leather wrote:
> > On Sun, Aug 14, 2016 at 9:48 PM, Tom wrote:
> >>
> >> Is there a reason to not allow '.' as a separator for Rational's Read
> >> instance, so that both "1%2" and "0.5" can be read?
> >
> > While it would make read :: String -> Rational more convenient, I'm not
> sure
> > it would be a good idea to have read accept input that will never be
> > produced by show :: Rational -> String.
>
> This already happens everywhere, right? For example, if you have a Foo
> { bar :: Int, baz :: String } with the derived read instance, this
> works:
>
> read "Foo{bar=0x01,      baz     =      \"h\101llo\"}" :: Foo
>

True. I'm not sure how far down the decimal/scientific notation parsing
hole you'd want to take the Ratio Read instance. Anyway, my point was that
there is an existing alternative that doesn't require changing the instance
and is not that inconvenient.

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160814/1fe289b5/attachment.html>


More information about the Haskell-Cafe mailing list