Skip to content

Conversation

@Bodigrim
Copy link
Collaborator

This fixes various issues with Cabal files, see individual commit messages for details.

…vision

parseCabalTarball relies on the assumption that the highest version
of a package is the last in 01-index.tar.gz. This is not necessarily
true in general (one can make a patch release in a long-term support
major version), but especially not true since Hackage gained a concept
of package revisions.

Each package revision is a separate entry in 01-index.tar.gz and it is
very common to revise old releases (because, say, they became incompatible
with new versions of dependencies). Thus Hoogle ends up with a random,
some times terribly outdated version of a package which just happened
to be revised recently.
hoogle-*.warn file contains 1000+ warnings caused by non-compliant parsing
of build-depends field in Cabal files. E. g., it warns that

hinstaller.cabal: Import of non-existant package Cabal>=1.2.3.0

The actual problem is that Hoogle expects a package name
to be separated from version bounds by a space, which is not
a requirement imposed by Cabal. So Hoogle literally looks
for a package named "Cabal>=1.2.3.0", not "Cabal".

After this commit the number of warnings decreases to ~100
and they all become genuine. E. g.,

cabal-install.cabal: Import of non-existant package Cabal-QuickCheck

Indeed, Cabal-QuickCheck is not on Hackage.
Now that we depend on Cabal-syntax anyway, why not use a proper
type to represent package names?
At the moment Hoogle just reads the license field as is,
which leads to suboptimal situation when
`hoogle search license:BSD3` and `hoogle search license:BSD-3-Clause`
return different (and disjoint!) results. We should do better
and normalise licenses as Cabal does.

By this point it's easier to migrate entire readCabal
to reading fields of GenericPackageDescription instead of
rolling out our own parser.
@Bodigrim Bodigrim merged commit 7ad8804 into ndmitchell:master Dec 4, 2025
5 checks passed
@Bodigrim Bodigrim deleted the fix-cabal-parsing branch December 4, 2025 00:41
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.

1 participant