Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard ML: how to compile a ML program using mosmlc?

Tags:

sml

I would like to compile my ML program into a executable binary using mosmlc. However, I could not find much information on how to do it.

The code that I'd like to compile is here http://people.pwf.cam.ac.uk/bt288/tick6s.sml

cx,cy,s,imgLocation are 4 arguments that I'd like to take from command line arguments. For instance, if the program is compiled with name mandelbrot, input bash$mandelbrot -0.5 0.15 0.0099 image.png should execute the main function.

like image 419
segfault Avatar asked Mar 07 '26 00:03

segfault


1 Answers

You should be able to put this code into a file foo.sml and run

mosmlc -P full foo.sml

To get the command-line arguments you want function CommandLine.arguments, so, e.g.,

val (cx, cy, s, imgLocation) = 
  case CommandLine.arguments () 
    of [a, b, c, d] -> (a, b, c, d)
     | _ -> (usage(); Process.exit Process.failure)

You'll have to write your own usage function.


P.S. If you have access to mosmlc, you probably also have access to the interactive mosml, which has an incredibly useful help function with type string -> unit.

like image 144
Norman Ramsey Avatar answered Mar 10 '26 14:03

Norman Ramsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!