[ghc-steering-committee] TypeApplications for Overloaded Literals (#129), Recommendation: accept

Simon Marlow marlowsd at gmail.com
Tue May 8 13:47:27 UTC 2018


On 6 May 2018 at 17:27, Iavor Diatchki <iavor.diatchki at 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.
>

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 <mail at 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 at joachim-breitner.de
>>   http://www.joachim-breitner.de/
>> _______________________________________________
>> ghc-steering-committee mailing list
>> ghc-steering-committee at haskell.org
>> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
>>
>
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20180508/13f22caa/attachment.html>


More information about the ghc-steering-committee mailing list