smltojs(1)

πŸ“¦
version 4.7.23 Β· 2 versions
, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay bestie, welcome to smltojs(1) β€” the manual for smltojs, aka the Standard ML to JavaScript compiler. This is the SMLtoJs compiler's page, and we're gonna get you fluent, fr fr.

✨ SYNOPSIS ✨

smltojs [OPTION]... [file.sml | file.sig | file.mlb]

All possible options are listed below. Yes, all of them, bestie.

πŸŽ€ DEFAULTS πŸŽ€

Factory settings, no cap β€” this is exactly what you get if you don't touch anything:

  • --SML_LIB You_did_not_set_path_to_install_dir
  • -aopt on
  • -verbose off
  • -c off
  • -timings off
  • -cfold on
  • --contract on
  • -cross_opt on
  • -debug off
  • --debug_linking off
  • --debug_man_enrich off
  • -dufa on
  • --eliminate_explicit_records on
  • -ebjs off
  • --fix_floating on
  • --high_pointer_tagging on
  • -basislib on
  • --inline_functors off
  • --js_dom_mode off
  • --js_path_compress off
  • -ltdce on
  • --log_to_file off
  • -max_inl_sz 200
  • -max_spec_sz 200
  • --messages on
  • --minimize_fixs on
  • --namebase dummyBase
  • -opt on
  • -o run
  • -j 1
  • --pretty_depth 5
  • --pretty_string_size 80
  • -Pceb off
  • --print_excon_name off
  • -Peb off
  • --print_lvar_name off
  • -Pole off
  • -Ppeast off
  • -Ptypestamps off
  • -Ptypes off
  • -quot off
  • --raggedRight on
  • -scratch off
  • --report_boxities off
  • -sig off
  • --safeLinkTimeElimination off
  • --specialize_recursive_functions on
  • -stats_opt off
  • --type_check_lambda on
  • --unbox_funargs on
  • -uncurry on
  • -w 100.

πŸ’… DESCRIPTION πŸ’…

When invoked, smltojs will compile the specified sources into an HTML-file, containing references to generated JavaScript files, through a series of translation phases. The various options can be used to control the printing of intermediate forms and to control which optimizations are performed. If source files are organised in ML Basis Files (files with extension .mlb), the compiler will memoize symbol table information and object code in the dedicated MLB directories located relative to the source files.

To learn more about programming with SMLtoJs, consult the SMLtoJs web page at

http://www.smlserver.org/smltojs

🌈 STANDARDS 🌈

SMLtoJs is based on the MLKit. The MLKit implements Standard ML (Revised 1997) and has almost full support for the Standard ML Basis Library (version of 2002).

πŸ“ EXAMPLES πŸ“

For examples, consult the SMLtoJs home page. That's the whole vibe here, bestie.

πŸ‘‘ OPTIONS πŸ‘‘

Here we go, one by one, with every flag and detail intact:

  • --SML_LIB S β€” installation directory for the MLKit standard library. For normal execution you should not modify this value. However, if you wish to use the MLKit with an altered runtime system you can update this setting and the system will try to link to a runtime system found in the specified install directory.
  • --aggressive_opt, -aopt β€” enable aggressive optimisations, including aggressive inlining. These optimisations are not guaranteed to be region safe. Turning off garbage collection automatically turns off this option.
  • --chat, -verbose β€” print a message for each compilation step in the compiler.
  • --compile_only, -c β€” compile only. Suppresses generation of executable.
  • --compiler_timings, -timings β€” show compiler timings for each compilation phase.
  • --constant_folding, -cfold β€” enable constant folding optimisations.
  • --contract β€” Contract is responsible for inlining, specialization, elimination of dead code, and much else (Lambda Expression Optimiser).
  • --cross_module_opt, -cross_opt β€” enable cross-module optimisation including inlining of small functions and specialisation of small recursive functions. Which optimisations are performed across modules is controlled by individual optimisation flags.
  • --debug_compiler, -debug β€” print intermediate forms of a program during compilation.
  • --debug_linking β€” debug linking of target code by showing which object files are linked together.
  • --debug_man_enrich β€” show information about why a program unit need be recompiled. A program unit (or a functor body) is recompiled if either (a) the program unit is modified, or (b) information about an identifier for which the program unit depends upon has changed.
  • --drop_unused_funargs, -dufa β€” drop function arguments that are unused.
  • --eliminate_explicit_records β€” eliminate bindings of explicit records only used for selections. Transform this:
let r = (e1,...,en) in ... #i r .. #j r ...

into this:

let x1=e1 in ... let xn=en in ... xi .. xj ...

(Lambda Expression Optimiser).

  • --export_basis_js, -ebjs β€” when this flag is enabled, SmlToJs writes pickled bases to file.eb.js files to be read by js-client.
  • --fix_floating β€” float fix-bindings into immediate let-bindings when possible to help tail-calls not be captured in let- region bindings.
  • --help β€” print extended help information and exit.
  • --help S β€” print help information about an option and exit.
  • --high_pointer_tagging β€” when enabled, the 16 most-significant bits in pointers may be used for tagging.
  • --import_basislib, -basislib β€” import Basis Library automatically in your projects. If you wish to make use of the Standard ML Basis Library in your projects, this option should be turned on, unless you wish to import the Basis Library manually in your projects.
  • --inline_functors β€” inline functors during static interpretation instead of generating separate target code blocks for functor bodies and arguments. With the flag enabled, performance may increase with the cost of larger (re)compilation times. The flag may be controlled in mlb-files using mlb- annotations.
  • --inline_names S β€” names of functions that should always be inlined if possible, no matter the setting of the flag --maximum_inline_size.
  • --javascript_library_paths S, -jslibs S β€” use this option to add javascript library paths to the generated html and thereby allow for SML code to reference existing JavaScript libraries.
  • --js_dom_mode β€” generate a full HTML document including a proper HTML DOCTYPE specification.
  • --js_path_compress β€” compress (make canonical) Javascript file path references in the resulting run.html file.
  • --js_path_prefix S β€” prefix to add to each non-absolute Javascript file path in the resulting run.html file.
  • --js_path_relative_to S β€” absolute directory for which each absolute Javascript file path is made relative to in the resulting run.html file.
  • --link_code S β€” link-files to be linked together to form an executable.
  • --link_time_dead_code_elimination, -ltdce β€” link time dead code elimination.
  • --load_basis_files S, -load S β€” basis files to be loaded before compilation proper.
  • --log_to_file β€” log to files instead of stdout.
  • --man β€” print man-page and exit.
  • --maximum_inline_size N, -max_inl_sz N β€” functions smaller than this size (counted in abstract syntax tree nodes) are inlined, even if they are used more than once. Functions that are used only once are always inlined. A function declared in one program unit may be inlined when applied in another program unit provided the function is sufficiently closed (refers only to exported identifiers) and provided the option --cross_opt is enabled.
  • --maximum_specialise_size N, -max_spec_sz N β€” function-parameterised functions smaller than this size (counted in abstract syntax tree nodes) are specialised if all applications of the function within its own body are applied to its formal function argument, even if they are used more than once. Functions that are used only once are specialised no matter their size. A function declared in one program unit may be specialised when applied in another program unit provided the function is sufficiently closed (refers only to exported identifiers) and provided the option --cross_opt is enabled. See also the option --specialize_recursive_functions.
  • --messages β€” print messages about reading source files and generating target files.
  • --minimize_fixs β€” minimize fix constructs (Lambda Expression Optimiser).
  • --mlb_path_maps S, -mlb-path-map S β€” ML Basis path map files to be used.
  • --namebase S β€” name base to enforce unique names when compiling mlb-files.
  • --no_aggressive_opt, -no_aopt β€” opposite of --aggressive_opt, -aopt.
  • --no_constant_folding, -no_cfold β€” opposite of --constant_folding, -cfold.
  • --no_contract β€” opposite of --contract.
  • --no_cross_module_opt, -no_cross_opt β€” opposite of --cross_module_opt, -cross_opt.
  • --no_drop_unused_funargs, -no_dufa β€” opposite of --drop_unused_funargs, -dufa.
  • --no_eliminate_explicit_records β€” opposite of --eliminate_explicit_records.
  • --no_fix_floating β€” opposite of --fix_floating.
  • --no_high_pointer_tagging β€” opposite of --high_pointer_tagging.
  • --no_import_basislib, -no_basislib β€” opposite of --import_basislib, -basislib.
  • --no_link_time_dead_code_elimination, -no_ltdce β€” opposite of --link_time_dead_code_elimination, -ltdce.
  • --no_messages β€” opposite of --messages.
  • --no_minimize_fixs β€” opposite of --minimize_fixs.
  • --no_optimiser, -no_opt β€” opposite of --optimiser, -opt.
  • --no_raggedRight β€” opposite of --raggedRight.
  • --no_specialize_recursive_functions β€” opposite of --specialize_recursive_functions.
  • --no_type_check_lambda β€” opposite of --type_check_lambda.
  • --no_unbox_funargs β€” opposite of --unbox_funargs.
  • --no_uncurrying, -no_uncurry β€” opposite of --uncurrying, -uncurry.
  • --optimiser, -opt β€” enable optimisation of intermediate language code (Lambda Expressions). Which optimisations are performed is controlled by individual flags. The optimisations include function inlining, function specialisation, fix-minimization, unboxing of function arguments, and elimination of unnecessary record constructions.
  • --output S, -o S β€” the name of the executable file generated by the Kit.
  • --parallel_compilation N, -j N β€” the maximum number of parallel processes used for compilation.
  • --pretty_depth N β€” this flag controls the pretty-printing depth of values printed in the REPL. The value must be an integer larger than zero.
  • --pretty_string_size N β€” this flag controls the pretty-printing size of strings printed in the REPL. The value must be an integer larger than zero.
  • --print_closed_export_bases, -Pceb β€” controls printing of closed export bases.
  • --print_excon_name β€” print underlying unique name when printing excons.
  • --print_export_bases, -Peb β€” controls printing of export bases.
  • --print_lvar_name β€” print underlying unique name when printing lvars.
  • --print_opt_lambda_expression, -Pole β€” print Lambda Expression after optimisation.
  • --print_post_elab_ast, -Ppeast β€” print ast after elaboration.
  • --print_type_name_stamps, -Ptypestamps β€” prints type name stamps and their attributes in types and expressions. πŸ’…
  • --print_types, -Ptypes β€” prints types when you’re printing intermediate forms. For Lambda Expressions, ordinary ML types get printed; for Region Expressions, region types get printed. ✨
  • --quotation, -quot β€” turns on support for quotations and anti-quotations. When it’s enabled, this datatype is available in the initial environment:
datatype 'a frag = QUOTE of string
                 | ANTIQUOTE 'a

Also, values of this datatype may be constructed using the quotation/antiquotation syntax:

val s = "world"
val a : string frag list = `hello ^s - goodbye`
  • --raggedRight β€” uses a ragged right margin when pretty-printing expressions and types. Very β€œlet the right edge live its truth” of it. πŸ¦‹
  • --recompile_basislib, -scratch β€” recompiles the basis library from scratch. This option is useful together with other options that control code generation. πŸ”₯
  • --report_boxities β€” reports the inferred boxity (representation) of every datatype declaration’s value constructors. So it’s giving β€œtell me the representation, bestie.” πŸŽ€
  • --report_file_sig, -sig β€” reports signatures for each file read. πŸ‘‘
  • --safeLinkTimeElimination β€” treats this module as a library in the sense that the code can be eliminated if it is not used, even if the code has side effects. Lowkey important: side effects do not save it from being eliminated here. πŸ’€
  • --specialize_recursive_functions β€” specialises recursive functions. Use the option maximum_specialise_size to control which functions are specialised. If this flag is on, functions that are applied only once are specialised, no matter the setting of --maximum_specialise_size (Lambda Expression Optimiser). 🌈
  • --statistics_after_optimisation, -stats_opt β€” reports optimisation statistics after optimisation of Lambda Expression. Numbers after the glow-up, basically. πŸ“Š
  • --type_check_lambda β€” type checks lambda expression prior to performing region inference. Type checking is very fast, and for normal use you should not disable this option. Type checking intermediate forms is very powerful for eliminating bugs in the compiler. 🫢
  • --unbox_funargs β€” unboxes arguments to fix-bound functions for which the argument 'a' is used only in contexts '#i a'. All call sites are transformed to match the new function (Lambda Expression Optimiser). 🧚
  • --uncurrying, -uncurry β€” enables uncurrying of curried functions. The uncurried function takes its arguments unboxed in registers or on the stack. For partial applications and non-application uses of the function, appropriate eta-expansions are applied. πŸ’œ
  • --version, -v, -V β€” prints version information and exits. Slay, short and iconic. ⭐
  • --width N, -w N β€” column width used when pretty printing intermediate code. N is the width, bestie. πŸŽ€

πŸ’€ EXIT STATUS πŸ’€

Exits with status 0 on success and -1 on failure. That’s the whole vibe check. βœ…βŒ


🌱 ENVIRONMENT 🌱

A library install directory must be provided in an environment variable SML_LIB, as a path-definition in the user’s personal path-map ~/.smltojs/mlb-path-map, or in a system wide path-map /nix/store/sfp5bfgah1f35wd1r96xrvhzx6nir1r6-mlkit-4.7.23/etc/smltojs/mlb-path-map.

bestie, it needs one of those three. Don’t leave it hanging. 🫢

πŸ“ FILES πŸ“

  • /nix/store/sfp5bfgah1f35wd1r96xrvhzx6nir1r6-mlkit-4.7.23/etc/smltojs/mlb-path-map β€” system-wide configuration of library and runtime system locations πŸ›οΈ
  • ~/.smltojs/mlb-path-map β€” user specific configuration of library and runtime system locations 🏠

πŸ’– CREDITS πŸ’–

SMLtoJs was developed by Martin Elsman. Many people have helped developing the MLKit on which SMLtoJs is built; see the MLKit home page for details. πŸ‘‘βœ¨


πŸ‘€ SEE ALSO πŸ‘€

See the MLKit manual β€œProgramming with Regions in the MLKit”, available from the MLKit home page

http://melsman.github.io/mlkit

for an in-depth introduction to programming with regions in the MLKit. 🌈

The home page also provides an overview of which parts of the Standard ML Basis Library the MLKit implements, along with download and installation instructions. πŸ¦‹


Catch you later, bestie β€” this is the smltojs(1) page, version v4.7.23. The footer didn’t hand me a date, so I’m not inventing one; just regions, flags, and vibes πŸ«ΆπŸ’–

πŸ“¦ where this page comes from