Closed brandonchinn178 closed 5 months ago
I don't immediately see a reason to use the CLI flags when one already has an .ormolu
file; is there a concrete use case?
But indeed, this was changed in #994, this seems to be the relevant review comment: https://github.com/tweag/ormolu/pull/994#discussion_r1168357940 (before that, the behavior you are expecting was preserved by that diff).
Perhaps this is where the expected behavior of refineConfig
fights with the usage in Main.hs
. From the perspective of refineConfig
, it makes sense that the passed-in fixity info should override the config passed in.
I personally don't see a concrete use-case for specifying fixities and reexports on the command line. But given that the flags exist, this is surprising behavior. I would be more in favor of removing the flags altogether than keeping the current behavior.
I think it is related to my remark here: https://github.com/tweag/ormolu/pull/994#discussion_r1168357940
I didn't have full context to understand the code when I wrote my review, and then @mrkkrp accepted my suggestion.
Now, I agree with @brandonchinn178 and I think CLI flags should have priority over config file ones. I suppose we could revert the change?
It is true that there is a conflict between semantics of refineConfig
and its usage in Main
, it did not occur to me before.
I would be more in favor of removing the flags altogether than keeping the current behavior.
I think the flags are very useful in situations when you don't want to write to the filesystem, e.g. in scripts when you want to execute a one-off action without extra state.
I will see if I can adjust this...
I think we should probably keep refineConfig
as is (it is reasonable for the arguments to override the "raw" config, after all) and instead change the way it is used in Main
.
Describe the bug
Reading the code here: https://github.com/tweag/ormolu/blob/49eb083d2b94ad882b1ff5f8b65f9870ee94a53d/src/Ormolu.hs#L193-L207
It seems like configuration in
.ormolu
files take precedence over command line flags, when the help text (and standard behavior of flags vs config files) seems to indicate that flags take precedence. Specifically,Map.union
is left-biased, sofixityOverrides
(coming frommfixityOverrides
, which comes frommDotOrmolu
) is preferred overcfgFixityOverrides rawConfig
(which is parsed from command line flags)To Reproduce
.ormolu
--fixity
Expected behavior Ormolu should format with the fixity specified on the command line
Environment
Additional context Add any other context about the problem here.