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

时间:2018-12-21 10:53:53

标签: haskell ghci

我可以使用:l addOne.hs

将具有单个功能的单个haskell文件加载到ghci中

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

addOne.hs

addOne x = x + 1

addTwo.hs

addTwo x = x + 2

还有其他几篇关于加载多个模块的文章。是达到上述要求的唯一方法,将它们转换为模块并调用

> :load Module1 Module2
> :module Module1 Module2

1 个答案:

答案 0 :(得分:3)

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

  

仅包含模块主体的模块的缩写形式是允许的。如果使用此选项,则假定标题为res.data

我认为您不能在{ "items":[ { "ibn":123, "name":"Harry Potter", "author":"J K Rowling", "genre":"fantasy", "publisher":"bloomsbury", "ebook":"yes", "audiobook":"yes", "summary":"the chosen one and he who must not be named", "rating":"5/5", "price":"500" }, { "ibn":456, "name":"Artemis Fowl", "author":"Eoin Colfer", "genre":"fantasy", "publisher":"viking press", "ebook":"yes", "audiobook":"yes", "summary":"the rich child theif and fairies", "rating":"5/5", "price":"540" }, { "ibn":789, "name":"war and Peace", "author":"Leo Tolstoy", "genre":"drama", "publisher":"wordsworth", "ebook":"yes", "audiobook":"yes", "summary":"the russian epic on war and peace after it", "rating":"5/5", "price":"700" }, { "ibn":135, "name":"metamorphosis", "author":"Franz Kafka", "genre":"absurdist fiction", "publisher":"kurt wolff", "ebook":"yes", "audiobook":"no", "summary":"a salesman turns into an insect", "rating":"4/5", "price":"400" }, { "ibn":791, "name":"coraline", "author":"Neil Gaiman", "genre":"dark fantasy", "publisher":"harper collins", "ebook":"yes", "audiobook":"yes", "summary":"the most adventurous person ever", "rating":"4.5/5", "price":"560" } ] } 中装入两个名称相同的模块(模块的真实名称;您可以使用别名合格的导入)。