繁体   English   中英

如何将多个仅具有功能(没有模块)的.hs文件加载到haskell ghci中?

[英]How to load multiple .hs files with only functions (no modules) into haskell ghci?

我可以使用:l addOne.hs具有单个功能的单个haskell文件加载到ghci中

如果我加载另一个haskell文件:l addTwo.hs它将擦除对另一个文件的引用,并且我得到Variable not in scope: addOneVariable not in scope: addOne尝试调用addOne时出现Variable not in scope: addOne错误

addOne.hs

addOne x = x + 1

addTwo.hs

addTwo x = x + 2

还有其他几篇关于加载多个模块的文章。 是实现以上将它们转换为模块并调用的唯一方法

> :load Module1 Module2
> :module Module1 Module2

参考: https : //www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1

允许使用仅由模块主体组成的模块的缩写形式。 如果使用此选项,则将标头假定为module Main(main) where

我认为您不能在ghci加载两个名称相同的模块(模块的真实名称;您可以使用别名限定导入)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM