2017-02-06 6 views
0

です。これは、 stack ghci not loading up local modules? の質問と同様ですが、まったく同じではありません。スタックghciはローカルモジュールをロードしませんが、ghciは

私はMain.hsとShapes.hsというファイルを持つディレクトリを持っています。ここで、Main.hsにはShapesというモジュールへの参照があります。

私は

ghci Main.hs

を実行すると、すべてが正常に動作します。これはバージョン7.10です。

しかし、私は、バージョン8で、

stack ghci

:load Main.hs

を実行する場合、私は、エラー

[1 of 1] Compiling Main (Main.hs, interpreted)

Main.hs:3:1: error:

Failed to load interface for ‘Shapes’

It is not a module in the current program, or in any known package.

Failed, modules loaded: none.

を取得し、私はリンク

:load Shapes.hs Main.hs

上の解決策を試してみましたが、それはまだありません作業。

How to avoid "‘main’ is not defined in module ‘Main’" when using syntastic

しかし、私がいた場合Main.hsファイルに

main :: IO()

に置くために:私は、この第二の問題について説明し、次を発見した

[1 of 2] Compiling Shapes (Shapes.hs, interpreted)

[2 of 2] Compiling Main (Main.hs, interpreted)

Main.hs:1:1: error:

The IO action ‘main’ is not defined in module ‘Main’

Failed, modules loaded: Shapes.

エラーが出ます、私はまだエラーが発生します。追加ラインを追加する場合は、最後にこれらの2行を追加してください。

main = return()

しかし、読み込んだ後はメインを終了し、メインの関数にアクセスすることはできません。 他のモジュールをインポートするときにIO機能を使用する必要はありません。バージョン8では、IOを使用せずにローカルモジュールをロードする方法を教えてください。

答えて

0

私自身の問題を修正しました。 Main.hsの上部にある、

module Main where

という行がありました。今私はスタックでロードする場合に動作します

:l Main.hs Shapes.hs

関連する問題