Using GHC API to compile Haskell file

Neil Mitchell ndmitchell at gmail.com
Fri Sep 4 12:40:19 UTC 2015


> Sorry about the delay; I hadn't gotten around to seeing if I could reproduce
> it. Here is a working copy of the program which appears to work with GHC
> 7.10.2 on 64-bit Windows:

Thanks, that does indeed solve it the first bit. To try and make it a
bit clearer what I'm after, I've put the stuff in a git repo:
https://github.com/ndmitchell/ghc-process/blob/master/Main.hs

Looking at Main.hs, there are three modes, Process (run ghc.exe 3
times), APIMake (the code you sent me), and APISingle (attempt to
replicate the 3 ghc.exe invokations through the GHC API). The first
two work perfectly, following Edward's tweaks. The final one fails at
linking. So I have two questions:

1) Is there any way to do the two compilations sharing some cached
state, e.g. loaded packages/.hi files, so each compilation goes
faster.

2) Is there any way to do the link alone through the GHC API.

Thanks, Neil


More information about the ghc-devs mailing list