Search code examples
haskellghcrunhaskell

How can I unhide ghc library using runhaskell


I'm building simple script with runhaskell and I try to use FastString from ghc-7.10.2. Simply:

import FastString

main = putStrLn "Hello SO"

running it with runhaskell Main.hs results in error:

Main.hs:1:8:
    Could not find module ‘FastString’
    It is a member of the hidden package ‘ghc-7.10.2’.
    Use -v to see a list of the files searched for.

I know that I can build it with cabal and specify ghc as dependency, but I really need to do it with runhaskell.

How can I unhide ghc library using runhaskell?


Solution

  • TL;DR:

    $ ghc-pkg expose ghc
    

    Well, runhaskell is basically a wrapper around runghc, and runghc is basically ghc. All of them follow the same rules: they can only import exposed packages from your configured database.

    Using ghc-pkg describe {package-name}, one can get information about a certain package. The important field here is exposed:

    $ ghc-pkg describe ghc | grep expose
    exposed: False
    exposed-modules:
    

    As you can see, the package isn't exposed (therefore it's hidden). Using ghc-pkg expose, you can unhide it:

    $ ghc-pkg expose ghc
    

    Keep in mind that you need permissions if you're changing the settings of your system wide package database.