Skip to content

Minor refactoring and improvements - #5464

Merged
qrilka merged 1 commit into
commercialhaskell:component-based-buildsfrom
theobat:comp/doc-and-refactoring
Mar 11, 2021
Merged

qrilka merged 1 commit into
commercialhaskell:component-based-buildsfrom
theobat:comp/doc-and-refactoring

Conversation

@theobat

@theobat theobat commented Jan 4, 2021 •

Copy link
Copy Markdown
Contributor
  • Rename lpWanted to lpShouldBeBuilt
  • Move printPlan and displayTask in thee Build.hs file (where Plan and Task are defined)
  • Isolate the merging of planTasks and planFinals into their own function (and remove mergeWithKeys as it's recommended to not use it in its haddock) defined in Build.hs.
  • A reorganization of toAction which transforms a task into an action. This was using very redundantly the Task constructor, and the task -> action is likely to change with component builds.
  • Rename W and M in ConstructPlan to more sensible names. Minor other changes there (changed the misnamed packageDepsWithTools).
  • Refactor Execute.hs and split the Precompiled/installed stuff into their own module.
  • Various haddock additions.
  • Remove PackageDepsOracle (unused)
  • Split ConstructPlan in 2 modules (the current one and its types)

@qrilka Note that I added small things since the pull request on master. Notably there was a non pure packageDepsWithTools accessor to package deps, which was only used once and had nothing to do with the actual accessing of package deps.
I have another pull request almost ready after this one which does some actual rework on Setup.hs, the Package datatype and the sublibrary dependencies.

@theobat
theobat force-pushed the comp/doc-and-refactoring branch from 3cde6a1 to efca500 Compare January 8, 2021 16:24

@qrilka qrilka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor comments

Comment thread src/Stack/Build/ConstructPlan.hs Outdated
tellExecutables :: PackageName -> PackageSource -> M ()
-- | Update the location of executables (if any) in the pdInstall map.
tellExecutables :: PackageName ->
-- | The package source for which the exe locations should (possibly) be updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor thing: I think normally we use postfix and not prefix haddocks for args i.e. -- ^
It's better to make code more consistent

Comment thread src/Stack/Build/ConstructPlan.hs Outdated
mlatestApplicable <- getLatestApplicableVersionAndRev
return $ Left (depname, (range, mlatestApplicable, DependencyMismatch $ adrVersion adr))
case partitionEithers deps of
_ <- addUnkownToolsWarning package

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of _ <- here?

Comment thread src/Stack/Build/Precompiled.hs Outdated
import Stack.Types.Execute
import Stack.Types.GhcPkgId
import Stack.Build.Cache
import Stack.PackageDump (conduitDumpPackage, ghcPkgDescribe)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stack's code base has different ways of formatting imports in different modules but I think it's better at least not to mix different ways in 1 module

Comment thread src/Stack/Types/Config.hs Outdated
-- | Dump information for a single package
-- | Dump information for a single package.
-- This is essentially a replicate of
-- <https://downloads.haskell.org/ghc/latest/docs/html/libraries/Cabal-3.2.0.0/Distribution-InstalledPackageInfo.html#t:InstalledPackageInfo the cabal ghc-pkg dump type>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/Stack/Types/Config.hs Outdated
-- <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#installedpackageinfo-a-package-specification see this>.
-- Why is this not the full cabal datatype ?
-- There seems to be no trace of components in this (at the ghc-pkg level at least, the
-- cabal type has it).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's possible to use Cabal to get this information and also this type and method of using ghc-pkg was created probably before this type (or at least component-related fields) appeared in Cabal.

Comment thread src/Stack/Types/Package.hs Outdated
-- Absent in cabal ? Comes from 'PackageConfig' 'packageConfigCabalConfigOpts'.
,packageFlags :: !(Map FlagName Bool)
-- ^ Flags used on package.
-- Absent in cabal ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/Stack/Types/Package.hs Outdated
--
,packageOpts :: !GetPackageOpts
-- ^ Args to pass to GHC.
-- Absent in cabal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theobat

theobat commented Jan 15, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for the review, I'll try to make the change quickly.

@theobat
theobat force-pushed the comp/doc-and-refactoring branch from efca500 to c450e39 Compare March 10, 2021 09:29
@theobat

theobat commented Mar 10, 2021

Copy link
Copy Markdown
Contributor Author

@qrilka sorry for the delay, I've been very busy at work. I've juste updated the PR.
I'm going to open another PR, which is not ready, but I'm kinf of stuck, and I think a review could help me see better what's going on.

@qrilka

qrilka commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

@theobat do you want me to review this one or the one you will open? Is there any particular problem you're stuck with?

@theobat

theobat commented Mar 10, 2021

Copy link
Copy Markdown
Contributor Author

I answered in #5504, It's still very messy, but it's in the right direction ! (maybe merging this one will ease the process of reviewing the mess in the other PR...)

@qrilka

qrilka commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

Thanks, I'll start with this one then

@qrilka qrilka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably a bit annoying but let's fixing the capitalization of Cabal and this could be merged

Comment thread src/Stack/Types/Package.hs Outdated
-- This is PackageIdentifier pkgName in Cabal.
,packageVersion :: !Version
-- ^ Version of the package.
-- This is PackageIdentifier pkgVersion in cabal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- This is PackageIdentifier pkgVersion in cabal.
-- This is PackageIdentifier pkgVersion in Cabal.

Comment thread src/Stack/Types/Package.hs Outdated
-- This is PackageIdentifier pkgVersion in cabal.
,packageLicense :: !(Either SPDX.License License)
-- ^ The license the package was released under.
-- This is PackageDescription licenseRaw in cabal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- This is PackageDescription licenseRaw in cabal.
-- This is PackageDescription licenseRaw in Cabal.

Comment thread src/Stack/Types/Package.hs Outdated
deriving (Show, Eq, Ord, Hashable, IsString, Generic, NFData, Data, Typeable)

-- | Some package info.
-- A lot of the fields are derived from cabal:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- A lot of the fields are derived from cabal:
-- A lot of the fields are derived from Cabal:

Comment thread src/Stack/Types/Package.hs Outdated
-- ^ Get all files of the package.
,packageDeps :: !(Map PackageName DepValue)
-- ^ Packages that the package depends on, both as libraries and build tools.
-- Derived from cabal:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Derived from cabal:
-- Derived from Cabal:

Comment thread src/Stack/Types/Package.hs Outdated
-- Note that this filters out _itself_ and all the non buildables.
,packageUnknownTools :: !(Set ExeName)
-- ^ Build tools specified in the legacy manner (build-tools:) that failed the hard-coded lookup.
-- Likely derived from cabal see the field just before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Likely derived from cabal see the field just before.
-- Likely derived from Cabal see the field just before.

Comment thread src/Stack/Types/Package.hs Outdated
--
,packageBenchmarks :: !(Set Text)
-- ^ names of benchmarks
-- Derived from cabal through:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Derived from cabal through:
-- Derived from Cabal through:

Comment thread src/Stack/Types/Package.hs Outdated
--
,packageExes :: !(Set Text)
-- ^ names of executables
-- Derived from cabal through:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Derived from cabal through:
-- Derived from Cabal through:

Comment thread src/Stack/Types/Package.hs Outdated
-- ^ Args to pass to GHC.
,packageHasExposedModules :: !Bool
-- ^ Does the package have exposed modules?
-- Derived from cabal's exposed modules list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Derived from cabal's exposed modules list
-- Derived from Cabal's exposed modules list

Comment thread src/Stack/Types/Package.hs Outdated
-- in the main lib.
,packageBuildType :: !BuildType
-- ^ Package build-type.
-- This is in cabal in <https://hackage.haskell.org/package/Cabal-3.2.1.0/docs/Distribution-PackageDescription.html#v:buildType buildType>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- This is in cabal in <https://hackage.haskell.org/package/Cabal-3.2.1.0/docs/Distribution-PackageDescription.html#v:buildType buildType>
-- This is in Cabal in <https://hackage.haskell.org/package/Cabal-3.2.1.0/docs/Distribution-PackageDescription.html#v:buildType buildType>

Comment thread src/Stack/Types/Package.hs Outdated
-- ^ If present: custom-setup dependencies
,packageCabalSpec :: !VersionRange -- ^ Cabal spec range
-- ^ If present: custom-setup dependencies
-- Derived from cabal 'SetupBuildInfo'.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Derived from cabal 'SetupBuildInfo'.
-- Derived from Cabal 'SetupBuildInfo'.

@theobat
theobat force-pushed the comp/doc-and-refactoring branch from c450e39 to 4965387 Compare March 11, 2021 08:50
- Rename lpWanted to lpShouldBeBuilt
- Move printPlan and displayTask in thee Build.hs file (where Plan and Task are defined)
- Isolate the merging of planTasks and planFinals into their own function (and remove mergeWithKeys as it's recommended to not use it in its haddock) defined in Build.hs.
- A reorganization of toAction which transforms a task into an action. This was using very redundantly the Task constructor, and the task -> action is likely to change with component builds.
- Rename W and M in ConstructPlan to more sensible names. Minor other changes there (changed the misnamed packageDepsWithTools).
- Refactor Execute.hs and split the Precompiled/installed stuff into their own module.
- Various haddock additions.
- Remove PackageDepsOracle (unused)
- Split ConstructPlan in 2 modules (the current one and its types)
- minor hlint suggestions
@theobat
theobat force-pushed the comp/doc-and-refactoring branch from 4965387 to f7bd275 Compare March 11, 2021 08:51
@theobat

theobat commented Mar 11, 2021

Copy link
Copy Markdown
Contributor Author

done !

@qrilka

qrilka commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

Thanks, I'll merge it when CI will finish its job

@qrilka
qrilka merged commit 056ef1e into commercialhaskell:component-based-builds Mar 11, 2021
@qrilka

qrilka commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

@theobat could you please rebase #5504 if you didn't do that yet? I plan to start checking it out this evening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants