Repository navigation
Description
Problems
with fields
These field names have the prefix with:
withPrograms :: ProgramConfigurationwithPackageDB :: PackageDBStackwithVanillaLib :: BoolwithProfLib :: BoolwithSharedLib :: BoolwithDynExe :: BoolwithProfExe :: BoolwithProfLibDetail :: ProfDetailLevelwithProfExeDetail :: ProfDetailLevelwithOptimization :: OptimisationLevelwithDebugInfo :: DebugInfoLevelwithGHCiLib :: Bool
In usual Haskell parlance, with indicates a function in continuation passing style, but these are simple accessors.
Singular/Plural
These fields refer to executables, libraries, or package databases in the singular, which is incorrect because we handle multiple of each simultaneously:
withPackageDB :: PackageDBStackwithVanillaLib :: BoolwithProfLib :: BoolwithSharedLib :: BoolwithDynExe :: BoolwithProfExe :: BoolwithProfLibDetail :: ProfDetailLevelwithProfExeDetail :: ProfDetailLevel
Duplicated fields
We have
withProfLib :: BoolandwithProfLibDetail :: ProfDetailLevelwithProfExe :: BoolandwithProfExeDetail :: ProfDetailLevel
when libProfiling :: Maybe ProfDetailLevel and exeProfiling :: Maybe ProfDetailLevel would be more idiomatic.
Essentially-unused fields
The program configuration in withPrograms :: ProgramConfiguration can't actually be serialized. Also, the programs in use can and often are reconfigured after the package is configured! Package configuration and program configuration are separate issues.
Proposed Solutions
- Rename the
with-prefixed fields. - Add fields
libProfiling :: Maybe ProfDetailLevelandexeProfiling :: Maybe ProfDetailLevel. - Split
LocalBuildInfointoPackageConfig(which would have most of the same fields asLocalBuildInfo) and a separateProgramConfiguration.
Compatibility
I can add deprecated accessors for all the renamed and removed fields. However, code which assigns those fields will have to change.
Splitting up LocalBuildInfo internally does not need to affect external code because we can always reconstruct a LocalBuildInfo for legacy interfaces.
Activity
ttuegel commentedon Jul 22, 2016
Related to refactoring discussion in #3589.
/cc @ezyang @23Skidoo @dcoutts
ezyang commentedon Jul 22, 2016
withProgramshas always been a giant wart. Good to get rid of this.withprefixed fields to? I have started using thelocal*prefix to indicateLocalBuildInfoaccessors but if you call itPackageConfigthe name is less apt. Note thatcabal-installalready defines aPackageConfigso best not to clobber the name.LocalBuildInfofor BC purposes? (I suppose we could.)LocalBuildInfosplit should be co-designed with the hooks API change. Do the hooks now take bothPackageConfigandProgramConfiguration? I guess there should be some environment type passed to the hook where it can get various information from?23Skidoo commentedon Jul 22, 2016
local*feels too generic, what aboutlbi*? Though I think that thewith*prefix is not that bad in this case, since those fields correspond to various--with-*flags ofconfigure.2 and 3 sound good.
ttuegel commentedon Jul 23, 2016
I was thinking of removing the prefixes entirely and using RecordWildCards, i.e.
packageDBs :: PackageDBStackvanillaLibs :: BoolsharedLibs :: BoolghciLibs :: BooldynamicExes :: Booloptimisation :: OptimisationLevelto facilitate
LocalBuildInfo {..}in function headers, but I don't know how everyone feels about that.I actually don't like how similar they are to the configure flags' names; they are emphatically NOT the flags passed to configure. In fact, we have some code that skims the
ConfigFlagsat build time, when it should really be reading settings from here.ezyang commentedon Jul 23, 2016
My uninformed opinion about record wild cards is they should only be used when it is manifestly obvious where the names come from. Otherwise I find it is too confusing to figure out the binding site of a record wild card.
ttuegel commentedon Jul 23, 2016
I agree, but I think that it is unambiguous because the
LocalBuildInfoshould be the canonical source of all the settings it contains.ezyang commentedon Jul 23, 2016
I mean, I'm not going to block you from using record wild cards if you really want to, but I will personally only use them in boilery-platey code; if it's a function like
configureI'd rather play nice and use the accessor manually.ttuegel commentedon Jul 24, 2016
Well, I will think more about how best to do this. It's not much of a "solution" if it doesn't meet everyone's needs! RecordWildCards was also my boilerplate-reduction strategy for the command-line flag structs. I definitely want to get this right; there's no need for haste!
ezyang commentedon Jul 24, 2016
I think the biggest problem people frequently have with RecordWildCards is that these bindings do shadow, and Cabal currently strives to be shadow free.
dcoutts commentedon Jul 25, 2016
Separating the program config is absolutely the right thing to do. The only reason they're currently mixed up was to avoid breaking the user hooks API.