Skip to content

Reading a Rational with zero denominator should fail?

Summary

When reading a String as a Rational number, there seems to be no nice way prevent an error when the rational's denominator is zero.

Steps to reproduce

(read "1%0") :: Rational

Expected behavior

I would expect readMaybe to return Nothing when the denominator is zero.

Environment

  • GHC version used: 8.8.3

If this seems like a good idea, I would be happy to attempt a patch

Edited by bwroga
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information