Remove redundant divZeroError checks from (Integral Integer) instance
Motivation
After discussing with Duncan Coutts and @hsyl20 , it seems that the division by zero checks inside Integral Integer
instance are redundant for those GHC versions that rely on ghc-bignum.
Taken from: https://hackage.haskell.org/package/base-4.19.0.0/docs/src/GHC.Real.html#line-491
instance Integral Integer where
...
!_ `quot` 0 = divZeroError
!_ `rem` 0 = divZeroError
!_ `div` 0 = divZeroError
!_ `mod` 0 = divZeroError
!_ `divMod` 0 = divZeroError
!_ `quotRem` 0 = divZeroError
...
All these checks for zero are redundant because the underlying ghc-bignum backend would check and raise the exception anyway.
See also Note [ghc-bignum exceptions]
in https://hackage.haskell.org/package/ghc-bignum-1.3/docs/src/GHC.Num.Primitives.html
There may be other places that contain redundant checks (Natural/BigNat?), but I have not looked further into that.
Proposal
- Remove all divZeroError checks for Integral Integer instance in GHC master.
- (optional) backport it to all ghc-bignum-enabled GHCs' , using a minor version release.