Skip to content

Fix #406 by nubbing module list generated from source files - #408

Merged
sol merged 2 commits into
sol:masterfrom
andreasabel:issue-406
Nov 10, 2020
Merged

sol merged 2 commits into
sol:masterfrom
andreasabel:issue-406

Conversation

@andreasabel

@andreasabel andreasabel commented Nov 10, 2020 •

Copy link
Copy Markdown
Contributor

Fix #406 by nubbing module list generated from source files

Inserting a nub here is strictly improving the state of affairs, since cabal chokes on a module list with duplicates.

This patch might also fix #353.

Version 0.34.2 has already been released.
Inserting a `nub` here is strictly improving the state of affairs,
since cabal chokes on a module list with duplicates.

This patch might also fix sol#353.
@andreasabel andreasabel changed the title Issue 406 Fix #406 by nubbing module list generated from source files Nov 10, 2020
@andreasabel

andreasabel commented Nov 10, 2020 •

Copy link
Copy Markdown
Contributor Author

CI failed, but I do not think this is due to my patch:

The travis-ci job BUILD=tinc CABALVER=2.2 GHCVER=8.4.3 apparently has problems
https://travis-ci.com/github/sol/hpack/jobs/431630342

GHC 8.4.3 crashes when building cabal:

Building library for Cabal-3.2.1.0..
[ 55 of 242] Compiling Distribution.CabalSpecVersion ( Distribution/CabalSpecVersion.hs, dist/dist-sandbox-6fba3b3/build/Distribution/CabalSpecVersion.o )

ghc: panic! (the 'impossible' happened)

  (GHC version 8.4.3 for x86_64-unknown-linux):

	Prelude.!!: index too large

Maybe try GHC 8.4.4 instead.

tinc: callProcess: cabal "install" "--bindir=$prefix/bin/$pkgid" "Cabal-3.2.1.0" "base-compat-0.11.2" ...
... "http-client-tls-0.3.5.3" (exit 1): failed

@sol
sol merged commit 604b364 into sol:master Nov 10, 2020
sol added a commit that referenced this pull request Nov 10, 2020
Comment thread src/Hpack/Module.hs
then do
src <- Directory.canonicalizePath (dir </> src_)
removeSetup src . map toModule <$> getModuleFilesRecursive src
removeSetup src . nub . map toModule <$> getModuleFilesRecursive src

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this use nubOrd instead?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I was considering this as well. I'm not eager to require containers >= 0.6 though. We can add our own inline definition.

@andreasabel andreasabel Nov 10, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I shouldn't have used nub, I know, it is evil.
Instead, since getModules returns a sorted list, one could have applied uniq in the end which just removes consecutive duplicates.

uniq = map head . group

Or even better, modify sortModules to remove duplicates.

sortModules = map Module . Set.toAscList . Set.fromList . map unModule

If you dare to derive Ord for Module, then just:

sortModules = Set.toAscList . Set.fromList 

UPDATE: forget the Set alternative, I see that sort is special (Hpack.Util.sort).

andreasabel added a commit to andreasabel/hpack that referenced this pull request Nov 10, 2020
Since the final list of modules is sorted, it is sufficient to throw
out consecutive duplicates, in the style of linx command `uniq`.
@sol

sol commented Dec 7, 2020

Copy link
Copy Markdown
Owner

@andreasabel I just released hpack-0.34.3 to Hackage (fyi).

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.

Duplicate entries in connection with Alex and Happy Handle hsc files more robustly

3 participants