标准ML / NJ:加载到函数文件中

时间:2015-06-10 20:16:55

标签: functional-programming sml

我试图在SML文件中编写一堆函数,然后将它们加载到解释器中。我一直在谷歌搜索并遇到这个:

http://www.smlnj.org/doc/interact.html

本节有哪些内容:

Loading ML source text from a file

The function use: string -> unit interprets its argument as a file name relative to sml's current directory and loads the text from that file as though it had been typed in. This should normally be executed at top level, but the loaded files can also contain calls of use to recursively load other files.

所以我在当前目录中有一个test.sml文件。我跑sml,到目前为止都很好。然后我尝试use test.sml;并得到:

stdIn:1.6-1.14 Error: unbound structure: test in path test.sml

不确定为什么这不起作用。有什么想法吗?

谢谢, bclayman

1 个答案:

答案 0 :(得分:2)

正如您所提到的,函数use的类型为string -> unit。这意味着需要string并返回unit。当你执行use test.sml时,你没有给它一个字符串。您需要use "test.sml"(注意引号)

相关问题