-
Notifications
You must be signed in to change notification settings - Fork 233
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-directed API search #459
Comments
The branch experimental-polarity implements such feature, but there is not yet any user-interface. The query language use variance of types to direct the search, e.g. "-string +int" finds a way to produce an int from a string. It is limited to type constructors at the current time, no objects nor variants. Do you have any suggestion on the GUI to put above that? |
A useful start would be equivalent to the vim interface's |
What about the results? ... Sublime text will be the less painful to bind to such feature :). |
This would suggest the following interface:
|
I opened #612 to track my developments related to this feature. |
Since this sounds a lot like Hoogle (but, you know, not for Haskell), https://github.com/ndmitchell/hoogle/ might be a good source of user interfaces to rip off |
Almot 9 years after, tada: #1828 |
This is a feature request.
It would be really nice if Merlin could perform Coq-like type-directed searches, similar to what
SearchPattern
does in Coq.The main use case I would have for this feature would be to query "which functions can produce a type M.t"? Or "which functions use this type M.t"? All that in the context of a large code base where the user needs a value of type
C.t
and he knows that functionf: A.t -> B.t -> C.t
exists, but then he wonders how to produce aB.t
in order to give it tof
, and then he finds out after much effort that a functiong: D.t -> B.t
exists, but then he has to find out how to obtain aD.t
...Here's an example, adapted from the Coq reference manual:
Note that, in Coq's case, trying to match
nat -> bool
will produce results includingnat -> nat -> bool
as well, which may or may not be useful (it might return too many results).In Coq's SearchPattern, the underscore character is used as a sort of "wildcard", when the user does not care about which types to consider. Here's a fictitious example using OCaml's
Int32
:Polymorphic types may or may not be an issue (in terms of syntax):
Other queries might involve specific modules:
In principle, this last use case might be dealt with by directly grepping the
.ml
/.mli
file. However, if there areinclude
d modules coming from other files, or modules which are only part of a given file, querying would be faster than grepping each of them.I have no idea what should be done with variant types or objects, since I rarely use them.
Note that this is almost exactly what ocamloscope does, but that project seems to have had little development lately, and it requires building a database which might require recompiling OPAM packages, etc. In principle Merlin already knows which files to look at (those in
.merlin
), and it already parses the files anyway, so in theory (from a very naive point of view), it would just need to store the type information for the parsed functions in a mini-database and make it accessible via queries.Finally, note that while the generic
SearchPattern
might be very complicated, specialized queries such asproduces-type <type-pattern>
oruses-type <type-pattern>
would already be very handy and possibly much simpler to code.The text was updated successfully, but these errors were encountered: