> There's also an issue with ghci being inherently stateful -- this can
> lead to hard-to-diagnose bugs where the IDE state gets out of sync with
> ghci's state. IMO, ideally, all state (that's not simple caching or
> front-loading of cache) really needs to reside in the IDE itself -- the
> layer below it should be as stateless as possible. (I realize that e.g.
> cabal-install[1] are stateful, but ideally it *shouldn't* be and
> hopefully there'll be some upcoming work to move it in that direction.)
Yes, that is the concept for Scion (v2). I stopped working on it at
some point because it was so messy to get the necessary information
out of GHC. I did a little GHC API proof of concept with GHC 7.10
recently. That looks more promising. Also, Stack could take care of a
lot of build issues.
The basic idea is:
- Building is not managed by GHC's --make mode. Instead an external
build manager (e.g., based on Shake) invokes compiler in one-shot
mode.
- The compiler is basically GHC + hooks.
- The compiler generates .hi files, optionally .o files, and .meta
files. This contains all meta data which may grow over time: error
messages, parse tree, renamed/typechecked code
A (logically) separate service manages and caches additional
information derived from the meta data. For example,
- all error messages in the whole project (or which ones might be
outdated because a dependency has changed)
- definition sites of all identifiers in the project
- use sites of things
- etc.
The IDE layer would sit on top of this separate service.
Open issues:
- How are projects specified? Ideally stack based.
- How are custom build steps integrated?
- Will this work for GHCi?
I talked about this with Duncan Coutts (who was involved in the
backend that FP Complete IDE work) and they came to basically the same
conclusion. This work has now been open sourced, but I only took a
brief look at it a while ago. Probably worth another closer look.
/ Thomas