IDEs, and programming language tools in general, translate software facts (obtained from source code, library definitions, object files, etc.) and user input to other useful forms, such as editor or compiler actions, and diagrams. My proposal:
- Separate queries and commands
- query examples:
- find location of definition of
foo
- find all locations that
reference fromMaybe
- find all possible completions at some location (e.g. my cursor):
completions <FILE> <LINE> <COL>
- find location of definition of
- command examples:
compile <FILE>
visit-location <FILE> <LINE> <COL>
- query examples:
- Define a DSL for both
- Specify the query and the software fact model that goes with it in terms of something well-understood. I opted for datalog here. Note that this does not mean that an implementation (e.g.
haskell-ide
) would have to use an actual generic datalog solver. - However, it should be capable of answering some subset of queries, and invoke editor commands based on their result(or vice versa. For example, it would be capable of answering the query ‘find location of definition of
foo
’, and invokevisit-location
on its result. - The model could easily be reusable across (functional) languages: Haskell, Frege, PureScript, Elm, etc.
Try the knowledge base in Test1.prolog
(which is really only datalog) by pasting it into the left pane here:
http://ysangkok.github.io/mitre-datalog.js/wrapper.html
Some example queries to try, in the pane on the right:
completions_for_module(X, test1)?
defined_at_loc(pure, U, L)?
used_at_loc(pure, F, R, C)?
doc(pure, URL)?
type_cons(X)?
defined_in_trans(X, maybe_mod)?