Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 618
remdezx Avatar asked Dec 03 '15 11:12

remdezx


1 Answers

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.

like image 83
Zeta Avatar answered Sep 24 '22 12:09

Zeta