MLWorks allows you to produce executables from ML applications. This process is known as delivery.
Applications can be delivered using the function MLWorks.Deliver.deliver. This function takes two arguments:
unit -> unit. This is the function to be evaluated when the image is loaded
To be specific, suppose you have defined the following function. It may have been defined in a file that was compiled and loaded, or in a file that was called with use, or by typing directly in the listener.
fun hello () = print "Hello, world.\n";
The print function is available at top-level in MLWorks, so you do not need to read any library code into MLWorks, nor require any libraries, to make this example work. For a delivery example that does use other libraries, see Section 3.5 on page 49, which delivers a simple program that uses the Standard ML Basis library for I/O.
By invoking MLWorks.Deliver.deliver from a listener, you can now deliver the function hello as an application:
MLWorks> MLWorks.Deliver.deliver ("hello.img", hello);
The executable file hello, considering what it does, may seem quite large. However, this is because it must contain a copy of the MLWorks runtime. This is a constant overhead (somewhat under 300 KB), so is less significant for larger programs..