Proposal: Accept proposal 37, Hex Float literals

Hello, I was assigned to be the shepherd for the Hex Float proposal ( https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC. This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits. The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10 This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers. The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals. I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet. Please let me know if you have any objections or suggestions on what might needs to be changed. Cheers, -Iavor

Looks good to me.
Iavor Diatchki
: Hello,
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37 https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers, -Iavor
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

No objections from me. Looks useful and not too costly in terms of extra
complexity.
On 27 February 2017 at 21:34, Iavor Diatchki
Hello,
I was assigned to be the shepherd for the Hex Float proposal ( https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers, -Iavor
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

One tricky bit that occurred to me: we can't really change the behavior of
the Read instance depending on the extensions enabled.
Thus, we would either have to always parse hex floats, even when the
extension is not on, or never parse them.
I am leaning towards parsing them always, even without the extension. What
do others think?
-Iavor
On Tue, Feb 28, 2017 at 5:36 AM, Simon Marlow
No objections from me. Looks useful and not too costly in terms of extra complexity.
On 27 February 2017 at 21:34, Iavor Diatchki
wrote: Hello,
I was assigned to be the shepherd for the Hex Float proposal ( https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers, -Iavor
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

Hi,
I think that's fine, and the benefits outweigh the downsides.
This is treading on CLC space a bit, though. Should we coordinate with them?
Joachim
Am 28. Februar 2017 09:30:16 PST schrieb Iavor Diatchki
One tricky bit that occurred to me: we can't really change the behavior of the Read instance depending on the extensions enabled.
Thus, we would either have to always parse hex floats, even when the extension is not on, or never parse them.
I am leaning towards parsing them always, even without the extension. What do others think?
-Iavor
On Tue, Feb 28, 2017 at 5:36 AM, Simon Marlow
wrote: No objections from me. Looks useful and not too costly in terms of extra complexity.
On 27 February 2017 at 21:34, Iavor Diatchki
wrote: Hello,
I was assigned to be the shepherd for the Hex Float proposal ( https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers, -Iavor
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org
https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

This is a well written proposal. Hex float literals as proposed are
fine and I am in favor of it. Hex notation for floats has pedagogical
benefits as well.
The deviation in the proposal is from the C standard, not the IEEE
standard and essentially brings the proposal into conformance with the
IEEE spec anyway. I'd suggest that we concern ourselves more
exclusively with IEEE compliance than mimicking the C spec.
This is CLC territory but for backwards compatibility we might suggest
that a newtype be offered for re-obtaining the old Read instance for
Double as a temporary compatibility affordance. (2-3 releases?)
Beyond that, this should be good to go.
On Tue, Feb 28, 2017 at 11:58 AM, Joachim Breitner
Hi,
I think that's fine, and the benefits outweigh the downsides.
This is treading on CLC space a bit, though. Should we coordinate with them?
Joachim
Am 28. Februar 2017 09:30:16 PST schrieb Iavor Diatchki
: One tricky bit that occurred to me: we can't really change the behavior of the Read instance depending on the extensions enabled.
Thus, we would either have to always parse hex floats, even when the extension is not on, or never parse them.
I am leaning towards parsing them always, even without the extension. What do others think?
-Iavor
On Tue, Feb 28, 2017 at 5:36 AM, Simon Marlow
wrote: No objections from me. Looks useful and not too costly in terms of extra complexity.
On 27 February 2017 at 21:34, Iavor Diatchki
wrote: Hello,
I was assigned to be the shepherd for the Hex Float proposal ( https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows: - allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for: - the literals start with 0x - the digits are in hex - the exponent symbol is `p` or `P`, instead of `e` or `E` - the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed: - the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise - should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232) - there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211 - changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely - there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066 I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers, -Iavor
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org
https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
-- Chris Allen Currently working on http://haskellbook.com

Hi, Am Dienstag, den 28.02.2017, 15:13 -0600 schrieb Christopher Allen:
This is CLC territory but for backwards compatibility we might suggest that a newtype be offered for re-obtaining the old Read instance for Double as a temporary compatibility affordance. (2-3 releases?)
not sure how useful that is. It will not easily be used in derived Read instances of datatypes that use Double. I’d like to hear from someone who has an actual use case for this first. Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

I’m also fine with this hex-floats thing
What’s the protocol? Should committee discussion take place by default on the proposal thread itself, with exceptional out-of-band private discussion on the mailing list? Or by-default private on the mailing list?
Simon
From: ghc-steering-committee [mailto:ghc-steering-committee-bounces@haskell.org] On Behalf Of Simon Marlow
Sent: 28 February 2017 13:37
To: Iavor Diatchki

Hi, Am Mittwoch, den 01.03.2017, 09:59 +0000 schrieb Simon Peyton Jones:
What’s the protocol? Should committee discussion take place by default on the proposal thread itself, with exceptional out-of-band private discussion on the mailing list? Or by-default private on the mailing list?
I guess we have not had a serious discussion yet, so this part of the process still needs to be fleshed out. One can argue both ways. I don’t really care either way. Why don’t we just see what people prefer to do naturally for a while, and maybe only then document what we end up doing? Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

Am Montag, den 27.02.2017, 13:34 -0800 schrieb Iavor Diatchki:
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
there seems to be consensus on this. If nobody shouts out real soon now, I will official mark this as approved tomorrow or so. Greetings, Joachim -- -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

Joachim Breitner
Am Montag, den 27.02.2017, 13:34 -0800 schrieb Iavor Diatchki:
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
there seems to be consensus on this. If nobody shouts out real soon now, I will official mark this as approved tomorrow or so.
Sounds good to me. Cheers, - Ben

Hi, Am Montag, den 20.03.2017, 19:26 -0400 schrieb Joachim Breitner:
Am Montag, den 27.02.2017, 13:34 -0800 schrieb Iavor Diatchki:
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
there seems to be consensus on this. If nobody shouts out real soon now, I will official mark this as approved tomorrow or so.
I think it would set better procedural precedent if the shepherd does that. Iavor, can you mark the proposal as accepted (with a small rationale) and close the PR? Thanks, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

OK, I've marked it as accepted.
On Mon, Mar 27, 2017 at 8:18 AM, Joachim Breitner
Hi,
Am Montag, den 20.03.2017, 19:26 -0400 schrieb Joachim Breitner:
Am Montag, den 27.02.2017, 13:34 -0800 schrieb Iavor Diatchki:
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37), so I would like to propose that we accept it for implementation in GHC.
there seems to be consensus on this. If nobody shouts out real soon now, I will official mark this as approved tomorrow or so.
I think it would set better procedural precedent if the shepherd does that. Iavor, can you mark the proposal as accepted (with a small rationale) and close the PR?
Thanks, Joachim
-- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
participants (7)
-
Ben Gamari
-
Christopher Allen
-
Iavor Diatchki
-
Joachim Breitner
-
Manuel M T Chakravarty
-
Simon Marlow
-
Simon Peyton Jones