
31 May
2020
31 May
'20
2:17 p.m.
On Sun, 31 May 2020, Dannyu NDos wrote:
I mean, shouldn't there be a guard?
instance (Integral a, Read a) => ReadPrec (Ratio a) where readPrec = parens . prec 7 $ do n <- step readPrec lift (expect (Symbol "%")) d <- step readPrec guard (0 /= d) return (n % d)
I think you are right. A readPrec parser should only generate parser errors and should be total. I do not know if anyone relies on the current behavior. I suspect that most users are not aware of the problem and their programs will be aborted in case of zero denominator where they shouldn't.