Skip to content

NumDecimals documentation insufficient

Summary

Location of documentation issue: the GHC user's guide, section 6.9.4. Fractional looking integer literals

IMO this section does not adequately describe the effect of the NumDecimals extension. Apparently it has given at least one person the impression that this extension causes a mere Num constraint to be placed on any numeric literal, rather than only those that represent integer numbers. It also refers to Integral despite that class not being involved in the desugaring either way as far as I can tell.

Proposed improvements or changes

It should probably explicitly describe which literals are desugared with fromInteger and which with fromRational, without and with the extension enabled, or at least make explicit that literals which represent non-integer fractions retain the Fractional constraint.

It may additionally be useful to mention the interaction of NumDecimals with HexFloatLiterals (which is exactly as one would expect).

As a last minor quibble, I feel “Fractional looking” in the title could use a hyphen.

Environment

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