Skip to content

Separate out Package utilities & enforce better typing discipline#1502

Open
isovector wants to merge 12 commits intohaskell:masterfrom
tweag:package-utils
Open

Separate out Package utilities & enforce better typing discipline#1502
isovector wants to merge 12 commits intohaskell:masterfrom
tweag:package-utils

Conversation

@isovector
Copy link
Copy Markdown
Contributor

@isovector isovector commented May 4, 2026

This PR moves the Utilities section out of Distribution.Server.Packages.Types and into Distribution.Server.Packages.Utils. It then adds:

+data MetadataRevision = MetadataRevision
+  { metaRevCabalFile :: CabalFileText
+  , metaRevInfo :: UploadInfo
+  }
+  deriving stock Show

-type UploadInfo = (UTCTime, UserId)
+data UploadInfo = UploadInfo
+  { uploadInfoTime :: UTCTime
+  , uploadInfoUser :: UserId
+  }
+  deriving stock Show

These new datatypes used to be anonymous tuples, and their new existence gives an easy-to-target API for the work in #1486. This PR is careful to not use the new MetadataRevision constructor anywhere, so that it can be trivially swapped out for a structure that can be pulled out of the database.

In addition, we keep OldUploadInfo around, since swapping it inside of the acid-state would be a breaking serialization change. Furthermore, all of the utility implementations are copied verbatim into Packages.Utils.Acid, since they're still required for *.State maintenance, and will diverge more dramatically in upcoming PRs.

This PR also changes the type of pkgDesc:

-pkgDesc :: PkgInfo -> GenericPackageDescription
+pkgDesc :: MetadataRevision -> GenericPackageDescription

which makes it clear that it is a function of a specific revision, rather than of the package-as-a-whole. This in turn revealed some bugs in the feed code, which was using the wrong dates. I will send a separate PR fixing those issues.

Comment thread src/Distribution/Server/Features/PackageFeed.hs Outdated
Comment thread src/Distribution/Server/Features/PackageFeed.hs Outdated
Comment thread src/Distribution/Server/Features/PackageList.hs Outdated
Comment thread src/Distribution/Server/Features/PackageList.hs Outdated
Comment thread src/Distribution/Server/Pages/Recent.hs
Comment thread src/Distribution/Server/Pages/Recent.hs
Comment thread src/Distribution/Server/Pages/Recent.hs Outdated
@isovector isovector marked this pull request as draft May 4, 2026 19:30
@isovector isovector marked this pull request as ready for review May 4, 2026 22:35
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