#7266: Allow fractional-looking integer literals
------------------------------+---------------------------------------------
Reporter: shachaf | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.6.1 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Testcase:
Blockedby: | Blocking:
Related: 2245 |
------------------------------+---------------------------------------------
Haskell 2010 (2.5, 6.4.1) specifies that there are integer literals and
floating literals, which are of types `(Num a) => a` and `(Fractional a)
=> a` respectively. This is mostly reasonable, because a `Rational` in
general can't be converted to an arbitrary `Num` instance.
However, there are many specific cases where specifying an integer with
compact "floating literal" syntax is reasonable (e.g. `1.2e6` instead of
`1200000`). It's possible to do that for any floating literal constant
which also happens to be an integer.
Several people have asked for that behavior. Attached is a patch for a
proposed extension, `NumDecimals`, that implements it.
Note on #2245: The current fix won't work on converted floating literals,
because it involves a special case for `FractionalLit` (the right thing to
do is probably to generalize that solution, but doing that properly might
be complicated). So with the extension enabled, `1e400` would be pretty-
printed as an integer (just like 0400 is pretty-printed). Unlike the
example in #2245, though, no information is lost -- floating literals
would just be printed in integer form.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7266>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs