TypeApplications for Overloaded Literals (#129), Recommendation: accept

Dear Committee, this is your secretary speaking: Sandy Maguire proposes to change the desugaring of overloaded literals so that they work nicely with type applications https://github.com/ghc-proposals/ghc-proposals/pull/129 rendered at https://github.com/isovector/ghc-proposals/blob/type-apps/proposals/0000-typ... I’ll shepherd that myself. The proposal is a good example for a working proposal system here. The original version of the proposal was rather complex, reshuffling type arguments and stuff. But community input distilled this much smaller change, which can be summarized: Desugar `5` into `integerLit (5 :: Integer)` where integerLit :: Integer -> forall a. Num a => a integerLit = fromInteger This allows `5 @Int` to work just fine. The proposal does not require a language extension, and does not change what happens in the light of `RebindableSyntax`. I therefore recommend that we accept this proposal. Cheers, Joachim -- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/

Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Also, there appears to be a typo in the spec, the part which specifies
translations for integers (1 turned into 0?)
-Iavor
On Sun, May 6, 2018 at 7:25 AM Joachim Breitner
Dear Committee,
this is your secretary speaking:
Sandy Maguire proposes to change the desugaring of overloaded literals so that they work nicely with type applications https://github.com/ghc-proposals/ghc-proposals/pull/129 rendered at
https://github.com/isovector/ghc-proposals/blob/type-apps/proposals/0000-typ...
I’ll shepherd that myself.
The proposal is a good example for a working proposal system here. The original version of the proposal was rather complex, reshuffling type arguments and stuff. But community input distilled this much smaller change, which can be summarized:
Desugar `5` into `integerLit (5 :: Integer)` where
integerLit :: Integer -> forall a. Num a => a integerLit = fromInteger
This allows `5 @Int` to work just fine.
The proposal does not require a language extension, and does not change what happens in the light of `RebindableSyntax`.
I therefore recommend that we accept this proposal.
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

Hi, Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed. (BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.) Cheers, Joachim -- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/

I am not convinced, if that's the sole motivation. By that reasoning you
might expect that `(-5) @Int` or `(5+1) @Int` would also work, but they
wouldn't.
On Sun, May 6, 2018 at 8:47 AM Joachim Breitner
Hi,
Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because
Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double
is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed.
(BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.)
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/ _______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

I'm also unconvinced about this proposal. It's hard to specify, requiring that Prelude.fromInteger be magical. Note that if someone defined a separate Num class (under -XNoImplicitPrelude -XRebindableSyntax) that's fully equivalent to Prelude.Num, it wouldn't work. Also, Joachim's point about `:t 5` is a poor motivation: `:t` does not give you helpful information w.r.t. type applications. You need `:t +v`. With -fprint-explicit-foralls, λ> :t +v 5 5 :: forall {p}. Num p => p The appearance of the braces in the output means that 5 is not available for visible type application (the variable p is *inferred*). So if there's any unexpected behavior in the current implementation, that's due to ill-informed expectations, not misbehavior. In the end, I would prefer to reject this proposal in favor of Joachim's casual proposal here: https://mail.haskell.org/pipermail/ghc-steering-committee/2018-May/000541.ht... (and expanded upon by my subsequent post). Richard
On May 6, 2018, at 12:27 PM, Iavor Diatchki
wrote: I am not convinced, if that's the sole motivation. By that reasoning you might expect that `(-5) @Int` or `(5+1) @Int` would also work, but they wouldn't.
On Sun, May 6, 2018 at 8:47 AM Joachim Breitner
mailto:mail@joachim-breitner.de> wrote: Hi, Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because
Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double
is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed.
(BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.)
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.de mailto:mail@joachim-breitner.de http://www.joachim-breitner.de/ http://www.joachim-breitner.de/ _______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org mailto:ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee 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

I’m on the fence:
* Benefit: slight
* Cost: slight
But the spec is distressingly ad-hoc. Magical behaviour if
* RebindableSyntax is no
* The ‘fromInteger’ in scope is not ‘Prelude.fromInteger’
So I lean to rejection. Unless some stronger motivations emerge.
Simon
From: ghc-steering-committee
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed. (BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.) Cheers, Joachim -- Joachim Breitner mail@joachim-breitner.demailto:mail@joachim-breitner.de http://www.joachim-breitner.de/ _______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.orgmailto: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.orgmailto:ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

Hi,
it seems this proposal does not get much support. I kinda like the high-level goal, but not enough to defend it vehemently. I am changing my recommendation to reject, to facilitate consensus.
I should give those time to speak up who were in silent agreement with my initial recommendation, and if nothing happens, will reject this proposal in a week's time.
Cheers,
Joachim
Am 8. Mai 2018 06:40:30 GMT-04:00 schrieb Simon Peyton Jones
I’m on the fence:
* Benefit: slight * Cost: slight
But the spec is distressingly ad-hoc. Magical behaviour if
* RebindableSyntax is no * The ‘fromInteger’ in scope is not ‘Prelude.fromInteger’
So I lean to rejection. Unless some stronger motivations emerge.
Simon
From: ghc-steering-committee
On Behalf Of Richard Eisenberg Sent: 06 May 2018 20:27 To: Iavor Diatchki Cc: ghc-steering-committee@haskell.org; Joachim Breitner Subject: Re: [ghc-steering-committee] TypeApplications for Overloaded Literals (#129), Recommendation: accept I'm also unconvinced about this proposal. It's hard to specify, requiring that Prelude.fromInteger be magical. Note that if someone defined a separate Num class (under -XNoImplicitPrelude -XRebindableSyntax) that's fully equivalent to Prelude.Num, it wouldn't work. Also, Joachim's point about `:t 5` is a poor motivation: `:t` does not give you helpful information w.r.t. type applications. You need `:t +v`. With -fprint-explicit-foralls,
λ> :t +v 5 5 :: forall {p}. Num p => p
The appearance of the braces in the output means that 5 is not available for visible type application (the variable p is *inferred*). So if there's any unexpected behavior in the current implementation, that's due to ill-informed expectations, not misbehavior.
In the end, I would prefer to reject this proposal in favor of Joachim's casual proposal here: https://mail.haskell.org/pipermail/ghc-steering-committee/2018-May/000541.ht... (and expanded upon by my subsequent post).
Richard
On May 6, 2018, at 12:27 PM, Iavor Diatchki
mailto:iavor.diatchki@gmail.com> wrote: I am not convinced, if that's the sole motivation. By that reasoning you might expect that `(-5) @Int` or `(5+1) @Int` would also work, but they wouldn't.
On Sun, May 6, 2018 at 8:47 AM Joachim Breitner
mailto:mail@joachim-breitner.de> wrote: Hi, Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because
Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double
is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed.
(BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.)
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.demailto:mail@joachim-breitner.de http://www.joachim-breitner.de/ _______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.orgmailto: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.orgmailto:ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

Hi, guess this one goes down as rejected. Will close it with a rationale. Cheers, Joachim Am Dienstag, den 08.05.2018, 08:20 -0400 schrieb Joachim Breitner:
Hi,
it seems this proposal does not get much support. I kinda like the high-level goal, but not enough to defend it vehemently. I am changing my recommendation to reject, to facilitate consensus.
I should give those time to speak up who were in silent agreement with my initial recommendation, and if nothing happens, will reject this proposal in a week's time.
Am 8. Mai 2018 06:40:30 GMT-04:00 schrieb Simon Peyton Jones
: I’m on the fence:
* Benefit: slight * Cost: slight
But the spec is distressingly ad-hoc. Magical behaviour if
* RebindableSyntax is no * The ‘fromInteger’ in scope is not ‘Prelude.fromInteger’
So I lean to rejection. Unless some stronger motivations emerge.
Simon
From: ghc-steering-committee
On Behalf Of Richard Eisenberg Sent: 06 May 2018 20:27 To: Iavor Diatchki Cc: ghc-steering-committee@haskell.org; Joachim Breitner Subject: Re: [ghc-steering-committee] TypeApplications for Overloaded Literals (#129), Recommendation: accept I'm also unconvinced about this proposal. It's hard to specify, requiring that Prelude.fromInteger be magical. Note that if someone defined a separate Num class (under -XNoImplicitPrelude -XRebindableSyntax) that's fully equivalent to Prelude.Num, it wouldn't work. Also, Joachim's point about `:t 5` is a poor motivation: `:t` does not give you helpful information w.r.t. type applications. You need `:t +v`. With -fprint-explicit-foralls,
λ> :t +v 5 5 :: forall {p}. Num p => p
The appearance of the braces in the output means that 5 is not available for visible type application (the variable p is *inferred*). So if there's any unexpected behavior in the current implementation, that's due to ill-informed expectations, not misbehavior.
In the end, I would prefer to reject this proposal in favor of Joachim's casual proposal here: https://mail.haskell.org/pipermail/ghc-steering-committee/2018-May/000541.ht... (and expanded upon by my subsequent post).
Richard
On May 6, 2018, at 12:27 PM, Iavor Diatchki
mailto:iavor.diatchki@gmail.com> wrote: I am not convinced, if that's the sole motivation. By that reasoning you might expect that `(-5) @Int` or `(5+1) @Int` would also work, but they wouldn't.
On Sun, May 6, 2018 at 8:47 AM Joachim Breitner
mailto:mail@joachim-breitner.de> wrote: Hi, Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 ::
Int`?
Because we can. Or rather, we should can, because
Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double
is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which
specifies translations for integers (1 turned into 0?)
thanks, fixed.
(BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.)
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.demailto:mail@joachim-breitner.de http://www.joachim-breitner.de/ _______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.orgmailto: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.orgmailto: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 -- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/

On 6 May 2018 at 17:27, Iavor Diatchki
I am not convinced, if that's the sole motivation. By that reasoning you might expect that `(-5) @Int` or `(5+1) @Int` would also work, but they wouldn't.
I was about to make the same argument, but then I realised that there's a counter argument - the user's intuition about TypeApplications is likely to start with something like "look at the type of the function in the left corner of this application". In the case of (-5), which is actually `negate 5`, the identifier is `negate`, and we've already lost the ability to use a type application when we applied it to 5. This is no different from something like `read "3" @Int` which also doesn't work. The problem with bare literals is that we can't see the function in the corner, and the user will tend to think of the literal itself as the function, so I think the confusion that Joachim mentions is real. That said, I have no strong opinions here and I haven't read the forall {k} proposal yet. Cheers Simon
On Sun, May 6, 2018 at 8:47 AM Joachim Breitner
wrote: Hi,
Am Sonntag, den 06.05.2018, 15:42 +0000 schrieb Iavor Diatchki:
Is there a reason why we should write `5 @Int` as opposed to `5 :: Int`?
Because we can. Or rather, we should can, because
Prelude> :t 5 5 :: Num t => t Prelude> :t 5 @Double <interactive>:1:1: error: • Cannot apply expression of type ‘t0’ to a visible type argument ‘Double’ • In the expression: 5 @Double
is confusing and inconsistent with the user’s expectation after learning about when they can use ExplicitTypeApplications (unless one knows about the syntactic sugar involved.)
Also, there appears to be a typo in the spec, the part which specifies translations for integers (1 turned into 0?)
thanks, fixed.
(BTW, all of you are owners of the repository and should have the necessary permissions to edit pull requests directly.)
Cheers, Joachim
-- Joachim Breitner mail@joachim-breitner.de http://www.joachim-breitner.de/ _______________________________________________ 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
participants (5)
-
Iavor Diatchki
-
Joachim Breitner
-
Richard Eisenberg
-
Simon Marlow
-
Simon Peyton Jones