Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Cache all types upfront #177

Open
kostmo opened this issue Sep 23, 2016 · 1 comment
Open

Cache all types upfront #177

kostmo opened this issue Sep 23, 2016 · 1 comment

Comments

@kostmo
Copy link

kostmo commented Sep 23, 2016

Not sure if this is a crazy idea or feasible.

Can ghc-mod (or something) create an index of all of the types in advance (akin to hasktags) so that if a project becomes un-compilable (e.g. mid-refactoring), one can still find out what the type of a given symbol was at the last time the project was compilable?

Java IDEs like Eclipse or IntelliJ somehow can still provide useful type information even when the project is in a non-compilable state.

@lierdakil
Copy link
Contributor

In case of syntax errors, not much can be done, sadly. However, if source is syntactically correct, but doesn't typecheck, ghc-mod usually can figure out most of the types that are not directly dependent on the part that doesn't typecheck, and even then there's some leeway. It is decidedly not possible to get consistent types though (since source doesn't typecheck).

If you're referring to the case where there's half-written code and you want to query types or something like that, learn to use undefined or typed holes (i.e. _) -- that's mostly what it's for anyway.

Generally speaking, gathering all types is feasible, although that would require changes to ghc-mod. But doing that every time source has changed will incur a sizeable performance penalty, especially on larger projects -- something I believe most users would prefer to avoid.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants