2014-10-01 2 views
7

Haskell wiki에서 얻은 간단한 예제를 실행하려고합니다. 내가 갖는GHC 패키지가 숨겨져 있습니다.

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 

오류 메시지는 다음과 같습니다

[email protected]$ 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. 

지금, ghc-7.8.3 내가, 컴파일을 할 사용하고 그래서 분명히 패키지가 설치되어있는 것입니다.

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

왜 GHC는 ghc 패키지를 볼 수없는 이유는 무엇입니까?

답변

5

실제로 대부분의 패키지가 숨겨져 있습니다.

일시적으로 숨기기를 해제하려면 ghc --make amy15.hs -package ghc-7.8.3을 사용할 수 있습니다.

영구히 숨기기를 해제하려면 @mhwombat suggested 메서드를 사용하십시오.

+0

숨겨진 이유는 무엇입니까? – Chinaxing

8

분명히 ghc 패키지가 Haskell 플랫폼을 설치하기보다는 수동으로 ghc를 수동으로 설치하는 경우 기본적으로 숨겨져 있습니다. 따라서 다음과 같이 패키지를 숨기기 취소해야했습니다.

sudo ghc-pkg expose ghc 
+2

또는 cabal을 사용하여 프로그램을 빌드하고'ghc' 패키지를 종속성으로 나열 할 수 있습니다. – Carl