NamedDefaults and relaxed defaults?

Benjamin Redelings benjamin.redelings at gmail.com
Wed Jul 26 16:59:48 UTC 2023


On 7/26/23 6:46 PM, Benjamin Redelings wrote:
>
> Thanks!
>
> It looks like ExtendedDefaultRules already allows default variables 
> that co-occur with multiparameter constraints and non-standard 
> classes.  So maybe that solves my issue with (Num a, Convertible a 
> Double).
>
It looks like (Num a, Convertible Double a) would work differently:

- with ExtendedDefaultRules, GHC would pick a ~ Integer (ignoring the 
Convertible constraint) and then complain that Convertible Double 
Integer has no instance.

- with NamedDefaults, GHC would reject a ~ Integer because Convertible 
Double Integer fails and then choose a ~ Double, which succeeds.

-BenRI

> Does the defaulting for RuntimeRep interact with class defaulting?
>
> -BenRI
>
> On 7/26/23 12:11 PM, Simon Peyton Jones wrote:
>> No: I don't know of anyone planning to implement this proposal -- 
>> indeed I had forgotten about it -- so it's waiting for someone to 
>> take it on.
>>
>> There are some slightly tricky loose ends around defaulting that it'd 
>> be good to nail down first: 
>> https://gitlab.haskell.org/ghc/ghc/-/issues/20686
>>
>> Simon
>>
>> On Wed, 26 Jul 2023 at 11:00, Benjamin Redelings 
>> <benjamin.redelings at gmail.com> wrote:
>>
>>     Hi,
>>
>>     If I understand correctly, the traditional defaulting rules prevent
>>     defaulting variables with constraints like (Num a, Convertible a
>>     Double), but the NamedDefaults proposal would allow defaulting a ~
>>     Double in this case due to the relaxed defaulting rules in
>>     section 2.5
>>     of the proposal:
>>
>>     https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0409-exportable-named-default.rst#id2
>>
>>     1. Is there any plan to start implementing NamedDefaults?  I saw the
>>     comment from Simon P-J that it would not be fun to implement
>>     because it
>>     might require orphan default declarations... so perhaps there's
>>     no plan
>>     to implement this?
>>
>>     2. Would it be worth adding a separate LANGUAGE option that just
>>     implements the relaxed defaulting rules in section 2.5?
>>     Specifically (a)
>>     allowing variables with multiparameter constraints and (b) allowing
>>     variables with constraints that are not in the Prelude.
>>
>>     3. Am I correct in assuming that the relaxed defaulting rules
>>     require
>>     NamedDefaults to be enabled in the importing module, and not just
>>     in the
>>     imported model?
>>
>>     -BenRI
>>     _______________________________________________
>>     ghc-devs mailing list
>>     ghc-devs at haskell.org
>>     http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20230726/be0f7cf0/attachment.html>


More information about the ghc-devs mailing list