The GHC API doesn't provide a good hscTarget option for tooling
Tools like ghc-mod typically just want TypecheckedModule
s. Sadly, the GHC API currently doesn't provide a good way to get at these in all cases (see this ghc-mod ticket). Each of the options we offer are cursed with their own limitations (largely quoting from the ghc-mod ticket),
HscNothing
At first glance this looks like what you would want. But...
-
Pros
* Doesn't generate code of any sort and is therefore rather lightweight
-
Cons
* It lacks support for Template Haskell
* Has trouble with
foreign export
s* Fails to issue pattern match checker warnings (#10600 (closed))
HscInterpreted
Okay, so HscNothing
doesn't work. Maybe HscInterpreted
is better?
-
Pros
* Supports Template Haskell
-
Cons
* Can't deal with unboxed tuples (#1257 (closed))
* Slower as we need to produce unnecessary bytecode
* Large memory footprint
* Also can't deal with
foreign export
s
HscAsm
-
Pros
* Supports all compilable code
-
Cons
* Slow
* Produces
.o
files
This is quite unfortunate. It seems like we need something in between HscNothing
and HscInterpreted
which is willing to use the interpreter to evaluate Template Haskell splices when necessary, but doesn't produce bytecode. Unfortunately it's unclear what to do about foreign export
(but arguably most tools would be fine with some approximate representation).