Repository navigation
Conversation
| @@ -0,0 +1,188 @@ | |||
| {-# LANGUAGE DeriveGeneric #-} | |||
There was a problem hiding this comment.
The interesting changes are mainly in this module.
|
I like this plan. Given the constraint that we want both flaggy and non-flaggy data types, I think this is the only possible thing you can do. I do have some inline comments so I'll put them in. |
| -- Portability : portable | ||
| -- | ||
| -- A monoid for command-line options such that successive options override | ||
| -- their precedents. |
There was a problem hiding this comment.
Obviously, eventually we should have docs for everything here.
|
I like this change.
Starting with base-4.8 you can also use |
Also, I don't think we want to pick up the stray instances. For example, |
|
There is one incompatible change here that I didn't think of before. Import lists like must now become On the one hand, this is a pretty breaking change. On the other hand, we have setup dependencies now, so in principle this is not so bad. Thoughts? |
|
That will break a lot of setup scripts. We'll probably have to change the default custom-setup upper bound to 1.26. /cc @hvr |
|
If that's much trouble, I could also increase the boilerplate level a notch by introducing separate data types for |
If that's indeed the case, the BC solution is of course preferable (if it's not too much trouble). |
|
I can maintain backwards compatibility with minimal boilerplate using |
|
Using |
|
I have been using something rather similar in a recent project, and used the following abstraction: One has to write that (boilerplaty) instance, but automatically gets: For that to work, SomeConf needs to have the form where
Not sure if this would be applicable for cabal, or if this would cause (more) breakage. |
|
@lspitzner Very interesting. Unfortunately we need to keep the old version of |
That's what I originally did, but we discovered that it breaks downstream import lists. However, I'm happy enough with the fully-compatible, separate So, I think it's a big win. |
|
I mostly agree with @23Skidoo here. But I'd also point out we can empirically find out how many packages would be affected (i.e. break) on Hackage to help decide whether it'd be more economical to retrofit setup-depends or tigthen cabal's implicit upper bound. |
|
Sure. I was in a "if we break things, break them correctly" mode, but if we can maintain BC that is better than avoiding small amounts of boilerplate. |
Agree 100%! 👍 Thanks for the feedback, everyone. I will close this for now and reopen when I have the complete, backwards-compatible refactoring. |
Before I get too deeply invested in this, I wanted to request feedback.
This begins to realize my vision for refactoring the
Flagtype in Cabal. I am trying to solve two problems:fromFlag.To get feedback, I have refactored
TestFlagsas a model for what I would like to do to the rest of the codebase. Except for deprecations and new exports, I have maintained API compatibility. I have not removed any exports or (AFAIK) changed the types of any exports.The
TestFlagstype is replaced withTestConfig awhereahas kind* -> *. The easiest way to understand what this type parameter does is to consider this synonym:which is equivalent to the old definition of
TestFlags.TestConfig a's sole constructor is namedTestFlagsto keep compatibility, I have just generalized the type.Besides
Flag, I have introducedand I provide
which calls
fromFlagOrDefaulton each field with the appropriate default values. The result offinalizeTestFlagsis aTestConfigwith all fields populated. For compatibility, there is a trivialwhich does the obvious thing. There is marginally more boilerplate this way, but I think having concentrated boilerplate is better than having
fromFlagthroughout the codebase. To organize the boilerplate better and reduce recompilation times, I am splitting upDistribution.Simple.Setup, starting withDistribution.Simple.Command.Test.Before I continue this refactoring for the other commands, do I hear any comments or objections?
/cc interested parties: @ezyang @23Skidoo @dcoutts