Which extensions should be part of the next GHC20xx?

The GHC20xx language editions seek to collect commonly-used and generally accepted extensions under a single flag. (Unlike Haskell2010, there’s no full standardization process, just the GHC user’s guide documentation.)

Given that we now have GHC2021 and GHC2024, we should start to think about GHC2027! (There’s no “official” decision to make GHC2027 the next iteration, but it would seem natural.) Which extensions would you like to see included?

To get things started, here’s my wishlist:

  • CApiFFI
  • DefaultSignatures
  • DerivingVia
  • LazyFieldAnnotations
  • RequiredTypeArguments (EDIT: perhaps not, given @int-index’s comments)
  • NoStarIsType
19 Likes

Thanks Adam!

My personal wish-list contains:

  • DerivingStrategies
  • DerivingVia
  • NoStarIsType
  • NumericUnderscores (if it’s not already part of GHC2024)

Regarding RequiredTypeArguments I’d encourage that you coordinate with @int-index in order to see if he feels the extension is ready for prime-time, and if it doesn’t work best with other extensions enabled.

While I’m mentioning extensions that should go together, OverloadedRecordDot and NoFieldSelectors are an absolute blast to have together, I wouldn’t want to enable one without the other!

10 Likes

I would like to see LexicalNegation becoming the standard.

It was already in GHC2021

6 Likes

Amazing, I’d happily look it up but the manual is down at the moment. :wink:

Let me quote myself:

Also, LambdaCase.

6 Likes

The good news: LambdaCase is already in.

2 Likes

In this discussion about the merits of ‘writing up’ GHC2024:

@AntC2 suggested that MultiParamTypeClasses (which is in) make ‘little sense’ without TypeFamilies or FunctionalDependencies (which are not in).

Separately, if I look at Stack’s use of pragmas (most of which are before my time), many modules have OverloadedStrings on top of GHC2024.

In other good news: DerivingStrategies is also already in.

3 Likes

Yes, it’s fair to say that MPTCs are a bit underpowered without either type families or fundeps. But MPTCs are a clearly reasonable common ground, whereas both additional options have different sets of dark corners around type inference. So I think for now it is reasonable to leave them both out of GHC20xx and let users enable one or both additionally when needed.

OverloadedStrings is an interesting case. It feels consistent with overloaded numbers, which have been included all along, and it might be a nice gentle nudge away from String towards e.g. Text. But turning it on can suddenly lead to confusing type inference ambiguities…

2 Likes

Will wonders ever cease!

RequiredTypeArguments change the way implicit quantification works. Including them in the next language edition would break the following code:

f :: map -> map
f x = x

I have chosen map simply as an example of a term-level identifier. Currently, it ends up implicitly quantified, as if the user wrote forall map., but with RequiredTypeArguments it captures the term-level map and reports an error:

error: [GHC-45510]
    • Term variable ‘map’ cannot be used here
        (term variables cannot be promoted)
    • In the type signature: f :: map -> map

If someone were to declare a = 42 at the top level, then f :: a -> a would stop working, too.

The first step toward enabling RequiredTypeArguments by default would be to move -Wterm-variable-capture to -Wdefault.

6 Likes

My wishlist:

  • UnliftedDatatypes - There really are no downsides
  • UnliftedNewtypes - Same

With mild downsides:

  • ExtendedLiterals
  • UnboxedSums
  • UnboxedTuples

These steal some syntax for using # as an operator without a space character. But all of those uses should already trigger warnings by default. (Although, due to a ghc bug they don’t currently trigger a warning. So a more conservative approach would be to fix this, and let the effects take hold before enabling these by default.

9 Likes

Hopefully QualifiedStrings will be included in GHC2034.

8 Likes

The 6 extensions you listed will be in addition to the defaults that ship with GHC2024, right ?

Is there a way we can know what all comes under -Wdefault ?

Isn’t that also true for overloaded numbers? Is there a difference?

Yes, I was assuming GHC2024 as a baseline. Of course there’s also the question of whether we should remove any extensions!

2 Likes

Currently -Wdefault is independent of the chosen language edition, and is set out in the GHC user’s guide:

1 Like

I think the only real difference is that numbers have been overloaded all along, whereas strings haven’t, so existing code will necessarily work with overloaded Num and APIs have been designed on that basis. Whereas turning on OverloadedStrings may break existing code in confusing ways.

1 Like

I would also like to add TypeAbstractions and remove ScopedTypeVariables.

5 Likes