barry(1)
π barry(1) β MLKit, a compiler for Standard ML π§
okay so bestie, welcome to barry β the fullblown Standard ML compiler from MLKit. yes, "fullblown" is the actual technical term here and honestly it ate. let's get into it β¨
πΈ NAME πΈ
barry β A fullblown Standard ML compiler. that's it. that's the whole vibe. no cap.
π¦ SYNOPSIS π¦
barry [OPTION]... [file.sml | file.sig | file.mlb]
All possible options are listed below. like, all of them, we're not hiding anything from you π
π DEFAULTS π
here's the starter pack β every single default the compiler ships with, exactly as it ships it, so you know what you're walking into π
--SML_LIBYou_did_not_set_path_to_install_dir β yeah, that's literally the default value, and yes it is a whole callout π set this fr fr-aopton-verboseoff-coff-timingsoff-cfoldon--contracton-cross_optoff-debugoff--debug_linkingoff--debug_man_enrichoff-dufaon--eliminate_explicit_recordson--fix_floatingon-basislibon--inline_functorsoff-ltdceon--log_to_fileoff-max_inl_sz200-max_spec_sz200--messageson--minimize_fixson--namebasedummyBase-opton-orun-j1--pretty_depth5--pretty_string_size80-Pceboff--print_excon_nameoff-Peboff--print_lvar_nameoff-Poleoff-Ppeastoff-Ptypestampsoff-Ptypesoff-quotoff--raggedRighton-scratchoff-sigoff--safeLinkTimeEliminationoff--specialize_recursive_functionson-stats_optoff--type_check_lambdaon--unbox_funargsoff-uncurryoff-w100
lowkey obsessed with how --SML_LIB's default value is just the compiler gently yelling at you. iconic behaviour honestly π
π DESCRIPTION π
so when you invoke barry, it compiles the sources you handed it into an executable file called run, and it does that by running through a whole series of translation phases β like a makeover montage but for your code π
β¨
the various options let you control:
- the printing of intermediate forms π
- which optimizations get performed β‘
and here's a cute detail: if your source files are organised in ML Basis Files (that's files with the extension .mlb), the compiler will memoize symbol table information and object code in the dedicated MLB directories located relative to the source files. so it remembers stuff for you. main character energy fr fr π
if you invoke barry without any source files at all, it starts an interactive REPL instead. type :help; inside the REPL to learn more about how to use it β go on, it's right there π«Ά
and if you wanna learn more about programming with MLKit, the MLKit web page is literally sitting there waiting for you at
http://melsman.github.io/mlkit
β STANDARDS β
the MLKit implements Standard ML (Revised 1997) and has almost full support for the Standard ML Basis Library (version of 2002). almost full, bestie β not fully full, so don't come for me π
see the MLKit home page for a detailed overview of the support for the Standard ML Basis Library. it's all documented, i promise π
π EXAMPLES π
for examples, consult the MLKit manual "Programming with Regions in the MLKit", which is available from the MLKit home page. yes, the regions one. go read it, it's giving essential reading πβ¨
π OPTIONS π
okay bestie, this is the part where barry really shows off. there are so many flags. grab a snack. every single one is here, no cap. π
--SML_LIB Sβ points at the installation directory for the MLKit standard library. for normal everyday vibes you do not touch this. but like, if you're feeling adventurous and wanna 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β turns on aggressive optimisations, including aggressive inlining. π heads up though: these optimisations are not guaranteed to be region safe. and turning off garbage collection automatically turns off this option. so like, it's giving bold. use responsibly.--chat,-verboseβ print a message for each compilation step in the compiler. it's the compiler narrating its life to you. π£οΈ--compile_only,-cβ compile only, bestie. suppresses generation of the executable. π--compiler_timings,-timingsβ show compiler timings for each compilation phase. perfect for when you need to know exactly which phase is being slow. β±οΈ--constant_folding,-cfoldβ enable constant folding optimisations. little constants get folded. iconic. π--contractβ Contract is responsible for inlining, specialization, elimination of dead code, and much else (Lambda Expression Optimiser). it's the main character of the optimiser tbh. π--cross_module_opt,-cross_optβ enable cross-module optimisation, including inlining of small functions and specialisation of small recursive functions. which optimisations get performed across modules is controlled by individual optimisation flags. π--debug_compiler,-debugβ print intermediate forms of a program during compilation. peek behind the curtain fr. π¦--debug_linkingβ debug linking of target code by showing which object files are linked together. so you can see exactly who's linking with who. messy but useful. π--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. like a little detective for your rebuilds. π--drop_unused_funargs,-dufaβ drop function arguments that are unused. bye bestie, you weren't doing anything anyway. π--eliminate_explicit_recordsβ eliminate bindings of explicit records only used for selections. it transforms:
let r = (e1,...,en) in ... #i r .. #j r ...
into:
let x1=e1 in ... let xn=en in ... xi .. xj ...
(Lambda Expression Optimiser). it's giving glow-up. β¨
--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. the classic. π«Ά--help Sβ print help information about an option and exit. just for one option, like a spotlight. π¦--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. honestly just leave it on unless you're built different. π--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. trade-off queen. βοΈ--inline_names Sβ names of functions that should always be inlined if possible, no matter the setting of the flag--maximum_inline_size. they're VIPs, they get in. ποΈ--link_code Sβ link-files to be linked together to form an executable. π--link_time_dead_code_elimination,-ltdceβ link time dead code elimination. dead code gets got at link time. π--load_basis_files S,-load Sβ basis files to be loaded before compilation proper. π--log_to_fileβ log to files instead of stdout. keeping the receipts in a file. π--manβ print man-page and exit. hi, you're reading the result of this rn. π--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. everyone gets a unique name, no duplicates allowed. π·οΈ--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_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. the whole package, honestly. π--output S,-o Sβ the name of the executable file generated by the Kit. name your child. πΆ--parallel_compilation N,-j Nβ the maximum number of parallel processes used for compilation. multitasking icon. β‘--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β print type name stamps and their attributes in types and expressions. π¨οΈ--print_types,-Ptypesβ print types when printing intermediate forms. for Lambda Expressions, ordinary ML types are printed, whereas for Region Expressions, region types are printed. π¨οΈ--quotation,-quotβ enable support for quotations and anti-quotations. when enabled, the datatype
datatype 'a frag = QUOTE of string
| ANTIQUOTE 'a
is available in the initial environment. moreover, values of this datatype may be constructed using the quotation/antiquotation syntax:
val s = "world"
val a : string frag list = `hello ^s - goodbye`
literally so cute. π
--raggedRightβ use ragged right margin in pretty-printing of expressions and types. π--recompile_basislib,-scratchβ recompile basis library from scratch. this option is useful together with other options that control code generation. clean slate energy. π§Ό--report_file_sig,-sigβ report signatures for each file read. π--safeLinkTimeEliminationβ treat 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. β οΈ yeah, even with side effects. read that again.--specialize_recursive_functionsβ specialise 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_inline_size... wait, no bestie, it's--maximum_specialise_sizeβ (Lambda Expression Optimiser). π
ok tiny correction for clarity: the original says functions applied only once are specialised no matter the setting of --maximum_specialise_size. (Lambda Expression Optimiser).
--statistics_after_optimisation,-stats_optβ report optimisation statistics after optimisation of Lambda Expression. numbers go brrr. π--type_check_lambdaβ type check 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β unbox 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β enable 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β print version information and exit. π·οΈ--width N,-w Nβ column width used when pretty printing intermediate code. π
π¦ EXIT STATUS π¦
exits with status 0 on success and -1 on failure. that's it, 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 ~/.barry/mlb-path-map, or in a system wide path-map /nix/store/sfp5bfgah1f35wd1r96xrvhzx6nir1r6-mlkit-4.7.23/etc/barry/mlb-path-map. like, pick a lane, but pick one. π«Ά
πΈ FILES πΈ
Okay bestie, so here's where barry actually looks for its config β pay attention, this part matters π
/nix/store/sfp5bfgah1f35wd1r96xrvhzx6nir1r6-mlkit-4.7.23/etc/barry/mlb-path-mapβ the system-wide config of where libraries and runtime system locations live πΊοΈ (yes, that is a very long Nix store path and no, you cannot shorten it, that's not me being dramatic, that's just Nix being Nix π)~/.barry/mlb-path-mapβ your own personal config of library and runtime system locations, because your setup can absolutely differ from the system one and that's valid π«Ά
Ngl, if barry is looking in the wrong place for something, these two files are the first thing you check. The user one is yours to vibe with, the system one is the system's.
π CREDITS π
Give it up for the icons who actually built this thing, fr fr π
The MLKit (version 2 and beyond) was developed by Lars Birkedal</>, Martin Elsman</>, Niels Hallenberg</>, Tommy H. Olesen</>, Mads Tofte</>, and Carsten Varming</>. Absolute legends, no cap π«‘
The following people also contributed with bug-fixes and improvements β and honestly, bug-fixers are the main characters we don't talk about enough: Peter Bertelsen</>, Vesa Karvonen</>, Ken Friis Larsen</>, Henning Niss</>, Peter Sestoft</>, and Troels Henriksen</>. Slay π
And for MLKit version 1 specifically, Nick Rothwell</> and David N. Turner</> took part in the development. OGs, genuinely π
π₯ SEE ALSO π₯
If you want the deep lore on regions, go read the MLKit manual called βProgramming with Regions in the MLKitβ β it's available straight from the MLKit home page:
http://melsman.github.io/mlkit
That manual is where you get an in-depth introduction to programming with regions in the MLKit, iykyk β¨
And the home page is also lowkey a whole vibe β it gives you an overview of which parts of the Standard ML Basis Library the MLKit implements, plus download and installation instructions. So like, everything you need in one place π¦
If you're sitting there wondering "does MLKit even implement this piece of the Basis Library?", bestie, the home page literally answers that. Go look π
π And that's the whole page, bestie! You made it to the end β proud of you π₯Ή This was barry(1) from version v4.7.23. Go forth, compile things, and remember: check your paths. Always check your paths π
β¨π
π¦ 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