-
Notifications
You must be signed in to change notification settings - Fork 50
Type search #55
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
Type search #55
Conversation
Ok, I think this is ready to review now. @hdgarrood We can probably use this to evaluate the quality of the search results that we'd be able to get from package set based search, to help decide whether it's worth the effort of maintaning package sets more generally. cc @soupi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nit but perhaps the URL path should be eg /type-search
to make it clear that this is only searching by type?
I don't think I know enough just yet to be able to help with issues like skolems vs unknowns.
flexMatches = search (replaceTypeVariablesAndDesugar (const P.TUnknown) elab) | ||
take 50 (strictMatches ++ flexMatches) | ||
Scotty.json $ A.object [ "results" .= [ P.showQualified P.runIdent k | ||
| (k, _) <- take 50 results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are doing take 50
twice? (Line 113)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it's deliberate. The idea is to explore the search space lazily for every combination of type constructors with the specified names. I want the nested searches to be bounded, but also the top-level search itself. Really I should probably use LogicT
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. Of course :)
This looks good to me but i'll have to take it for a spin to really understand what's going on. will try to do it later today :) |
Also, while I'm not sure how much effort it will be to maintain package sets, my expectation is that it will provide a huge benefit in helping people find install plans; even that on its own, without nice extras such as this type search, could well pay for itself I think. Having used Stackage I'm pretty confident that package sets are a good idea. Of course we're not quite at a stage where our tools can easily make use of package sets to help find install plans, but I do want to look at that at some point. |
I've deployed a first version, and you can try it here: @hdgarrood Sorry, I missed your comment about the route being |
Nice! Can we do anything to move functions like |
There's no simple way that I can think of, although Pursuit does have some code to estimate the number of instantiations required to unify two types. Perhaps we could reuse that?
Oh right, of course. We don't have that information in Try PureScript right now unfortunately. Like the compiler, it just receives a glob of source files on the command line. |
I was thinking of something like that, yeah. Might it make sense to put something like that into the compiler so that its suggestions based on this type search can benefit from that too? Ah ok, if that information isn't easily available then let's not worry about it for now. |
This is a work-in-progress.
The idea is to expose a
/search
endpoint which Pursuit can use to implement type search using the externs held by the Try PureScript process.I added this here instead of in a separate service since we already have the data in memory, and it seems wasteful to load it all twice on the server when we have limited resources.
The main issue is that replacing type variables with unknowns generally yields too many results. We could use skolems instead, which works better in some cases, but in other cases it gives too few results, since the generalization step doesn't work in the solver.
Another thing I would like to try is to resolve unqualified constructors by looking up any matching constructors in the
Environment
.