Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propose fuzzy-matched versions #557

Merged
merged 2 commits into from
Jul 13, 2015

Conversation

k-bx
Copy link
Contributor

@k-bx k-bx commented Jul 10, 2015

Fixes #504.

When you get a "Didn't see pkg- in your package indices" message,
also see list of candidates with same major version. Might be that you
forgot some minor thing like ".0" in the end of a version string.

Fixes commercialhaskell#504.

When you get a "Didn't see pkg-<ver> in your package indices" message,
also see list of candidates with same major version. Might be that you
forgot some minor thing like ".0" in the end of a version string.
import Network.HTTP.Download
import Path
import Prelude -- Fix AMP warning
import Prelude
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment shouldn't get lost, as someone may then accidentally remove the import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@snoyberg sorry, it was lost because of stylish-haskell, will bring it back

return $ Just bs

-- TODO: use 'Maybe (NonEmpty PackageIdentifier)' return-type
fuzzyLookupCandidates :: PackageIdentifier -> PackageCaches
Copy link
Contributor

Choose a reason for hiding this comment

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

It would probably be more efficient to convert PackageCaches into a Map PackageName (Set Version) to avoid traversing the entire collection for every mismatched name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@snoyberg yeah, I decided to not go for efficiency, as this seems like a rare piece of functionality. But since you mentioned it – I have no problem making it efficient then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@snoyberg I updated function to be better in terms of alg complexity. It now uses Map.splitLookup to do a logN-split, filtering smaller elements. It then filters bigger elements by doing takeWhile (takes only satisfying head).

Thus, I think I don't understand your comment in full. Since we're only running this algorithm for one package (I tested, if two packages didn't match we still fail and error only for the first one), the map-reconstruction for better version-matching wouldn't make a lot of sense. Might be that it would make sense in future, when we show errors for many packages at once.

@k-bx
Copy link
Contributor Author

k-bx commented Jul 10, 2015

I should note that I tested it on original repo with a problem:

Before:

➜  riak-haskell-client git:(protocol-buffers-nonfork) stack build
Didn't see protocol-buffers-2.1 in your package indices, updating and trying again

After:

➜  riak-haskell-client git:(protocol-buffers-nonfork) ✗ stack build
Didn't see protocol-buffers-2.1 in your package indices. Possible candidates: protocol-buffers-2.1.0. Updating and trying again.

snoyberg added a commit that referenced this pull request Jul 13, 2015
Propose fuzzy-matched versions
@snoyberg snoyberg merged commit 70d3021 into commercialhaskell:master Jul 13, 2015
@snoyberg
Copy link
Contributor

I'm going to merge in now, sans the minor efficiency concern. Feel free to send another PR if interested :)

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