GHC package is hidden

I am trying to run this simple example that I got from the Haskell wiki .

import GHC import GHC.Paths ( libdir ) import DynFlags main = defaultErrorHandler defaultFatalMessager defaultFlushOut $ do runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags target <- guessTarget "test_main.hs" Nothing setTargets [target] load LoadAllTargets 

The error messages I receive are as follows:

 amy@wombat $ ghc --make amy15.hs amy15.hs:1:8: Could not find module 'GHC' It is a member of the hidden package 'ghc-7.8.3'. Use -v to see a list of the files searched for. amy15.hs:3:8: Could not find module 'DynFlags' It is a member of the hidden package 'ghc-7.8.3'. Use -v to see a list of the files searched for. 

Now ghc-7.8.3 used for compilation, so obviously the package is installed.

 amy@wombat $ cabal info ghc * ghc (library) Versions available: [ Not available from server ] Versions installed: 7.8.3 ... and so on 

Why doesn't GHC see the ghc package?

+7
haskell ghc
source share
2 answers

Most packages are really hidden.

To temporarily display them, you can use ghc --make amy15.hs -package ghc-7.8.3 .

To display forever, use the suggested @mhwombat method.

+5
source share

Apparently, the ghc package is hidden by default, at least if you manually install ghc the way I do, rather than installing the Haskell platform. Therefore, I needed to "hide" the package as follows:

 sudo ghc-pkg expose ghc 
+8
source share

All Articles