smltojs(1)
π 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 tofile.eb.jsfiles to be read byjs-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 resultingrun.htmlfile.--js_path_prefix Sβ prefix to add to each non-absolute Javascript file path in the resultingrun.htmlfile.--js_path_relative_to Sβ absolute directory for which each absolute Javascript file path is made relative to in the resultingrun.htmlfile.--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_optis 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_optis 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 optionmaximum_specialise_sizeto 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.Nis 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
- nixpkgs unstable: mlkit 4.7.23
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms