GHCI에서 컴파일 된 객체 버전을 컴파일 할 때 컴파일 된 버전보다 훨씬 빠르도록로드하고 싶습니다. 이것은 모든 파일이 동일한 디렉토리 (모듈 계층이 없음)에있을 때 잘 작동했습니다. 그러나 파일이 모듈 계층에있을 때는 작동하지 않습니다.Haskell GHCI가 컴파일 된 객체 파일을로드하지 않음
근무 버전 MyFile.hs :
import Util.Basic
import Util.Histogram
: Basic.o 및 Histogram.o이 MyFile.hs
과 같은 디렉토리에 작동하지 버전 MyFile.hs 있습니다
import Basic
import Histogram
Basic.o 및 Histogram.o는 Util의 하위 디렉토리에 있습니다. MyFile.hs를로드 할 때이 버전 나는 다음을 얻을 :
[1 of 2] Compiling Util.Basic (Util/Basic.hs, interpreted)
[2 of 2] Compiling Util.Histogram (Util/Histogram.hs, interpreted)
Ok, modules loaded: Util.Basic, Util.Histogram.
내가 모듈 내 코드를 정리 여전히 파일 O를 컴파일 사용에서 혜택을받을 수 있도록하고 싶습니다
.
또한 o 파일이 컴파일 된 이후 소스 파일이 변경되지 않았 음을 유의해야합니다.
편집 :
import Util.Basic
import Util.Histogram
백분율/Basic.hs
module Util.Basic() where
백분율/Histogram.hs
module Util.Histogram() where
MyFile.hs : 여기 각 파일의 내용이다
파일/편집 : 다니엘에 의해 제안했다
$:~/programming/haskell/example-error$ ls
MyFile.hs MyFile.hs~ Util
$:~/programming/haskell/example-error$ cd Util
$:~/programming/haskell/example-error/Util$ ls
Basic.hs Basic.hs~ Histogram.hs Histogram.hs~
$:~/programming/haskell/example-error/Util$ ghc *.hs
[1 of 2] Compiling Util.Histogram (Histogram.hs, Histogram.o)
[2 of 2] Compiling Util.Basic (Basic.hs, Basic.o)
$:~/programming/haskell/example-error/Util$ ls
Basic.hi Basic.hs~ Histogram.hi Histogram.hs~
Basic.hs Basic.o Histogram.hs Histogram.o
$:~/programming/haskell/example-error/Util$ cd ../
$:~/programming/haskell/example-error$ ghci -ignore-dot-ghci MyFile.hs
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 3] Compiling Util.Histogram (Util/Histogram.hs, interpreted)
[2 of 3] Compiling Util.Basic (Util/Basic.hs, interpreted)
[3 of 3] Compiling Main (MyFile.hs, interpreted)
Ok, modules loaded: Util.Basic, Util.Histogram, Main.
*Main>
솔루션 :
The fix is to compile the importing file, and the files in the
subdirectory only as a consequence of that, not directly.
아, 좋습니다. 나는 당신이 서브 디렉토리에서 컴파일 된 것을 결코 상상하지 못했습니다. ghc로 가져와 가져온 파일을 찾아서 컴파일했다고 가정했습니다. –