Skip to content

Split up raw and complete types in pantry #4418

Closed

Description

@snoyberg

Basic goal: make it more type safe to convert between the raw input without complete package information and the fully resolved versions of packages:

-- Same idea for SnapshotLocation and SnapshotLayer

completePackageLocation :: RawPackageLocationImmutable -> m PackageLocationImmutable

data PackageLocation
  = PLImmutable !PackageLocationImmutable
  | PLMutable !(ResolvedPath Dir)

data PackageLocationImmutable
  = PLIHackage !PackageIdentifier !CabalFileHash !TreeKey
  | PLIArchive !Archive !PackageMetadata
  | PLIRepo    !Repo !PackageMetadata
  
data RawPackageLocationImmutable
  = RPLIHackage !PackageName !RawVersion !(Maybe TreeKey)
  | RPLIArchive !RawArchive !RawPackageMetadata
  | RPLIRepo    !RawRepo !RawPackageMetadata

data RawVersion
  = RVLatestAll
  | RVLatestRevision !Version
  | RVRevisionNumber !Version !Revision
  | RVRevisionHash !Version !CabalFileHash

data PackageMetadata = PackageMetadata
  { pmIdent :: !PackageIdentifier
  , pmTreeKey :: !TreeKey
  , pmCabal :: !BlobKey
  }

data RawPackageMetadata = RawPackageMetadata
  { rpmName :: !(Maybe PackageName)
    -- ^ Package name in the cabal file
    --
    -- @since 0.1.0.0
  , rpmVersion :: !(Maybe Version)
    -- ^ Package version in the cabal file
    --
    -- @since 0.1.0.0
  , rpmTreeKey :: !(Maybe TreeKey)
    -- ^ Tree key of the loaded up package
    --
    -- @since 0.1.0.0
  , rpmCabal :: !(Maybe BlobKey)
    -- ^ Blob key containing the cabal file
    --
    -- @since 0.1.0.0
  }

Activity

  1. qrilka commented on Nov 27, 2018

    @qrilka
    Contributor

    @snoyberg this refactoring appears to be larger than I expected it to be, I think as the 1st step I will just use RawXXX in Stack and then we could use proper types but for that some number of details need to get resolved, e.g. see this note - https://github.com/commercialhaskell/stack/blob/master/src/Stack/Build/Target.hs#L340

  2. snoyberg commented on Nov 27, 2018

    @snoyberg
    ContributorAuthor

    Regarding that note: once we have lock files in place, the lack of full reproducibility in a stack.yaml file isn't a problem anymore, since the lock file itself is the intended guarantee of reproducibility.

    Is this getting large enough that you want to back out of the change?

  3. qrilka commented on Nov 27, 2018

    @qrilka
    Contributor

    The current diff is

    36 files changed, 1139 insertions(+), 571 deletions(-)
    

    It's almost ready and on Stack side it uses previous "Raw" types at the moment, I didn't go into changing logic

  4. snoyberg commented on Feb 6, 2019

    @snoyberg
    ContributorAuthor

    Completed via PR by @psibi

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions