2017-02-06 30 views
0

这与 stack ghci not loading up local modules? 的问题类似,但不完全相同。栈ghci不加载本地模块,但ghci确实

我有一个目录Main.hs和Shapes.hs其中Main.hs有模块形状的引用。

如果我运行

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

在溶液中的错误,但它仍然不工作。我得到的错误

[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.

我发现了这个讨论第二个问题如下:

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

但如果我把在

main :: IO()

在Main.hs文件,我仍然有错误。如果我另外添加该行

main = return()

并且在最后有这两个附加行,那么它会加载。但加载后它只是退出主,我不再有权访问main中的函数。 我没有看到任何我需要使用任何IO功能的原因,当我导入其他模块时。我如何在版本8中加载本地模块而不使用IO?

回答

0

我修复了我自己的问题。 Main.hs中有一行叫做

module Main where

我删除了。现在它工作,如果我加载堆栈ghci与

:l Main.hs Shapes.hs