Skip to content

Potential Refactors

Mikhail Glushenkov edited this page Nov 8, 2018 · 11 revisions

Summary

Name Short description Estimated time Estimated difficulty Estimated risk PRs
UnresolvedPkgLoc Remove some maybes from PackageLocation, since in some places Nothing never gets used 2-3h 2/5 2/5
Dependency as constraint Separate it from the dependency-as-dependency ??? 3/5 4/5
Maybe UnqualComponentName Make it its own type 1-2h 1/5 1/5
In CmdInstall, make the when installLibs / when (not installLibs) blocks into helper procedures or top level functions 0.5h 1 1
Get rid of IsString instances for Cabal types (except ShortText) 4h 1 1

Details

UnresolvedPkgLoc

In ElaboratedConfiguredPackage.elabPkgSourceLocation, RemoteSourceRepoPackage cannot have a Nothing, but PackageLocation often has Maybe Filepath as local, leading to impossible cases like this one and silly code like this one.

We should remove the maybe wherever is possible.

@fgaz attempted this refactor here (remember to grep for undefined). Here's the only place where he found a Nothing: https://github.com/haskell/cabal/blob/26938a5958088f3cf493b79cab0bfcd3d0ca7c71/cabal-install/Distribution/Client/IndexUtils.hs#L316

Maybe PackageLocation should have two type params: one for RepoTarballPackage (which can be Nothing) and one for the rest. Or just one for RepoTarballPackage.

Dependency as constraint

See https://github.com/fgaz/gsoc/blob/master/2018/final-report.md#the-dependency-as-constraint-problem

The PackageVersionConstraint datatype is the new Dependency-as-constraint. Some places where it should be used here: https://github.com/haskell/cabal/issues/5570

Maybe UnqualComponentName

See https://github.com/fgaz/gsoc/blob/master/2018/final-report.md#the-pervasive-maybe-unqualcomponentname