Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using GHC2021 extensions by default #419

Closed
17 of 32 tasks
xsebek opened this issue Jun 17, 2022 · 4 comments · Fixed by #520
Closed
17 of 32 tasks

Consider using GHC2021 extensions by default #419

xsebek opened this issue Jun 17, 2022 · 4 comments · Fixed by #520
Labels
C-Low Hanging Fruit Ideal issue for new contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Meta This issue is about other Swarm issues or infrastructure.

Comments

@xsebek
Copy link
Member

xsebek commented Jun 17, 2022

Let us discuss the default-extensions field in swarm.cabal - I suggest we put there all the extensions that we use a lot and that are harmless and not very interesting.

AFAIK we can not use GHC2021 yet, but it is the current "standard" way of writing Haskell, based on some collected statistics, community votes and a few votes by committee.

PROs

  • cleans up the module header
  • highlights the more interesting extensions (looking at TH and undecidable instances 🤨)
  • makes it easier to use nice syntax sugar anywhere we like

CONs

  • some bikeshedding could take place
  • ?

Extensions

Here are the extensions that we use in Swarm along with their count with those in GHC2021 checked:

  • 1 AllowAmbiguousTypes
  • 1 BangPatterns
  • 1 BlockArguments
  • 1 DerivingStrategies
  • 1 GADTs (we could use GADTSyntax which is in GHC2021, related Why is Value defined as a GADT? #331)
  • 1 ScopedTypeVariables
  • 1 TemplateHaskellQuotes
  • 2 DefaultSignatures
  • 2 DerivingVia
  • 2 ImportQualifiedPost (we could require it with -Wprepositive-qualified-module)
  • 2 NumericUnderscores
  • 3 DeriveFunctor
  • 3 DeriveTraversable
  • 3 TypeOperators
  • 3 ViewPatterns
  • 4 StandaloneDeriving
  • 4 TypeFamilies
  • 4 UndecidableInstances
  • 5 DeriveDataTypeable
  • 5 PatternSynonyms
  • 5 QuasiQuotes
  • 6 DeriveAnyClass
  • 6 DeriveGeneric
  • 6 RankNTypes
  • 6 TupleSections
  • 8 FlexibleContexts
  • 8 TemplateHaskell
  • 9 LambdaCase (let's add this one too)
  • 10 MultiParamTypeClasses
  • 11 FlexibleInstances
  • 15 TypeApplications
  • 20 OverloadedStrings

What do you think? 🙂

@xsebek xsebek added Z-Feature A new feature to be added to the game. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Meta This issue is about other Swarm issues or infrastructure. and removed Z-Feature A new feature to be added to the game. labels Jun 17, 2022
@byorgey
Copy link
Member

byorgey commented Jun 17, 2022

Sure, sounds fine to me. It just makes it slightly harder for new contributors to figure out what is going on when reading the code. But maybe we could solve that by putting a standard comment at the top of every module pointing to the default-extensions field?

@byorgey
Copy link
Member

byorgey commented Jun 17, 2022

I like the idea of adding -Wprepositive-qualified-module. Import lists read so much better with ImportQualifiedPost.

@byorgey
Copy link
Member

byorgey commented Jun 17, 2022

I also like the idea of using GADTSyntax instead of GADTs where possible.

@byorgey byorgey added the C-Low Hanging Fruit Ideal issue for new contributors. label Jun 17, 2022
@xsebek
Copy link
Member Author

xsebek commented Jun 17, 2022

The documentation aspect is a good point. Eventually, the situation will be reversed, because all that stuff will be on by default in GHCi with I think 9.2 (and possibly also 9.0.2?).

We could definitely cherry-pick those that are self-explanatory (deriving, numeric underscore,...) and keep those that are a bit weird and not well known explicitly in files. For example, TupleSection and LambdaCase are non-Haskell2010 but were so popular in our Haskell university course that I think they were eventually allowed. 😏

I like the idea of adding -Wprepositive-qualified-module. Import lists read so much better with ImportQualifiedPost.

It also works better with HLS until I fix it - I have an open PR there, that I should get back to... 😅

I also like the idea of using GADTSyntax instead of GADTs where possible.

Totally, it was a nice discovery for me while I was reading about GHC2021. But we only use it in one place so far... 🙂

xsebek added a commit that referenced this issue Jun 30, 2022
@mergify mergify bot closed this as completed in #520 Jul 1, 2022
mergify bot pushed a commit that referenced this issue Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Low Hanging Fruit Ideal issue for new contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Meta This issue is about other Swarm issues or infrastructure.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants