Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling SML projects from multiple files

I've got a project with many files in it and I want it to work with most popular compilers.

Unfortunately, PolyML and SML/NJ require use statements, while MosML additionally requires explicitly loading basis library structures using load, which is not recognised by either poly or sml.

On top of that, MLton and MLKit require a completely different .mlb file simply listing filenames and also require an explicit import of basis library, which is done in a different way to MosML:

$(SML_LIB)/basis/basis.mlb

Is there some standard universal "include this file" command, and if it doesn't exist, is there some other way to have all compilers read from one entry-point file?

P.S. Wouldn't mind someone going on a small rant about compiler differences. I'm always interested in what people think and there's not too much info available :-)

like image 885
zlotnleo Avatar asked May 22 '17 01:05

zlotnleo


1 Answers

The use function is the standard universal "include this file" command, included in the Top-level environment

val use : string -> unit    implementation dependent

I generally maintain the build environment in smlnj's CM, then convert to mlb with cm2mlb. It will define a flag MLton when parsing the sources.cm file so that you can use that to work around differences in module loading behavior.

#if(defined(MLton))
runmain.sml
#endif

There is also a set of sml-buildscripts which converts from mlb to polyml. I am not familiar with them nor polyml however CM is convenient as the authoritative source, since it provides programmatic access from SML via the structure CM.

This is what cm2mlb uses, So while i'm not aware of anything which exists already that converts from CM to polyml, it should be possible.

like image 96
matt Avatar answered Oct 19 '22 08:10

matt