[Haskell-cafe] Integrate GHC-API with Cabal

Daniel Gröber dxld at darkboxed.org
Wed Jul 25 21:43:36 UTC 2018


On Wed, Jul 25, 2018 at 08:30:48PM +0200, Félix Baylac wrote:
> Thanks a lot for this really helpful message.
> > I think you might be interrested in one of my packages,
> > [cabal-helper](https://hackage.haskell.org/package/cabal-helper). It's
> > geard more towards editor tooling but I think it should work for your
> > use case too.
> Indeed, looks like what I'm looking for.
> > Basically you'd have to do `cabal install --only-dependencies && cabal
> > configure && cabal build` for each package you want to inspect and
> > then cabal-helpers API boils down to giving you a list of GHC
> > flags/module names you need to pass into the GHC API to make it work.
> > 
> > (The `cabal build` step is needed to run preprocessors like hsc2hs and
> > compile C dependencies, but once cabal has taken care of that you can
> > usually just load the package without problems.)
> I had to make some modifications and jump in some nix hoops to use 
> cabal-install instead of stack to build the packages, but indeed, it does work
> like a charm.

Ah, I forgot you said you were using Stack. You can use it too if you
prefer. You just have to use `stack path --dist-dir` (run in the
project directory) to get the path to the dist-dir after running
`stack build` instead of using the hardcoded `$PWD/dist` value. There
have been some reports of issues with stack using weird combinations
of Cabal-library versions though which so it might need some tweaking.

> This is perfect, I just tried your library following this example on the text
> package and it seems to do the job. Thanks a lot, fixing this problem without
> re-inventing the wheel is a huge relief.
> Do you mind if I write a small article on this integration. 

No not at all, send me a link when you're done.

> It'll probably prevent some other people from using dodgy hacks.

Well I'm not sure I would call cabal-helper not a dodgy hack but at
least it's a (sort of) well maintained hack :)


PS: Looks like I messed up the list-reply on my original message so I
resent it and I'm CC'ing haskell-cafe on this one. Sorry about that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180725/42883e73/attachment.sig>

More information about the Haskell-Cafe mailing list