Standard ML / NJ: Loading in file of functions

398 views Asked by At

I'm trying to write a bunch of functions in an SML file and then load them into the interpreter. I've been googling and came across this:

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

Which has this section:

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.

So I have a test.sml file in my current directory. I run sml, all good so far. Then I try use test.sml; and I get:

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

Not sure why this isn't working. Any ideas?

Thanks, bclayman

1

There are 1 answers

0
Matt On BEST ANSWER

As you mentioned, the function use has type string -> unit. This means it takes a string and returns unit. When you do use test.sml, you are not giving it a string. You need to do use "test.sml" (notice the quotes)