[Haskell-cafe] GHC API arguments via cabal/stack?
dct25-561bs at mythic-beasts.com
Sat Mar 12 08:29:39 UTC 2016
Cabal-helper looks like just the ticket, thanks!
On 11 Mar 2016 12:32, "Daniel Gröber" <dxld at darkboxed.org> wrote:
> On Fri, Mar 11, 2016 at 09:27:40AM +0000, David Turner wrote:
> > I've also briefly contemplated using the Cabal library to read my .cabal
> > file and work out what to do, but I'm unsure that this would work nicely
> > under stack. At least, I'm not sure quite what to do with all the package
> > databases and other stuff that stack does for you.
> Using the Cabal library to do this works very well in general, we do
> this in ghc-mod these days. The only way I've seen problems creep up
> so far is if cabal-install is linked against a different version of
> Cabal than your program. If your analysis program doesn't have to work
> on the same cabal dist directory as cabal-install (like ghc-mod does)
> then that's a non problem though.
> Anyways we've wrapped all the ugly stuff to work around this problem
> into a library called cabal-helper:
> Here's a little example program using that library which should do
> what you want:
> import System.Environment
> import System.Directory
> import System.Process
> import Distribution.Helper
> import Data.Char
> import Data.List
> main = do
> [project_dir] <- getArgs
> setCurrentDirectory project_dir
> dist_dir <- dropWhileEnd isSpace <$> readProcess "stack" ["path",
> "--dist-dir"] ""
> print =<< (runQuery (defaultQueryEnv "." dist_dir) $ ghcOptions)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe