Closed nikita-volkov closed 8 months ago
I did this on purpose. See #30 and https://github.com/tweag/ormolu/pull/471. My thought was that No*
extensions need to be sorted after everything else. Otherwise you may not be able to disable an extension that's implied by another one. For example you wouldn't be able to have default-extensions: ScopedTypeVariables NoExplicitForAll
(if for some weird reason you wanted that).
In practice I don't think people are likely to run into issues like that. Disabling extensions that are implied by other extensions is (I think) not that common, and it seems especially unlikely in default-extensions
. I could be convinced to simply sort these by name without any special care for No*
extensions. It would make the code simpler too:
It doesn't seem to be that the No
prefix is only used with a meaning of disabling extensions. E.g., with the mentioned NoImplicitPrelude
and NoMonomorphismRestriction
there seem to be no extensions that these would be disabling.
I could be convinced to simply sort these by name without any special care for No* extensions.
That's what I was implying actually. Sorry for not making it clear :)
I know they're documented that way, but extensions like NoImplicitPrelude
really do just mean "disable ImplicitPrelude
. It's just that most extensions are disabled by default, so only a few are typically written as No*
.
However I'm realizing now that my motivation is a little flimsy. Yeah, someone may want to have -XScopedTypeVariables
and -XNoExplicitForAll
, but they could just as well want -XRebindableSyntax
and -XImplicitPrelude
. This is what Ormolu tackles with its LanguagePragmaClass
. I'm not crazy about adding something like that to Gild.
Fortunately Gild has an escape hatch that Ormolu doesn't: You can have multiple default-extensions
blocks and they will be concatenated. So if you find yourself in a situation where one extension really needs to come before (or after) another, you can do this:
default-extensions: ScopedTypeVariables
default-extensions: NoExplicitForAll
That works because Gild doesn't merge values or reorder them.
Fixed in version 1.0.2.3.
E.g.,
Possible solution: sort them by their renderings using
sortWith
.