Closed jez closed 1 year ago
yeah, so right now millet only ships knowing about (most of) the standard basis library (plus some extra bits like Fn
and Random
).
to teach it about non standard other libraries like the ones sml nj ships with, we’d need to either add their signature in this repo (which is what i did for the two just mentioned), or somehow read them from an existing sml nj installation.
i predict the latter to be highly troublesome, since i’m not even sure eg sml nj ships with the source, it seemed to only ship compiled artifacts when i was looking into adding std basis support. not to mention the problem of locating an existing sml implementation on the user’s computer.
another idea: something like .d.sml (like .d.ts for typescript) or .smli (like .rbi for sorbet) for writing “interface files” for 3rd party deps. then it would be the responsibility of millet users to arrange the correct such files for whatever deps they use. this would probably “scale” better.
I also haven't found a way to read the basis library sources out of the SML/NJ installation on disk.
However, MLton ships with a command line flag -show-basis
:
mlton -show-basis foo.sml
This dumps the entire contents of the basis library into foo.sml
.
There might be existing SML/NJ flags to inspect which libraries are available and their locations dynamically. You could consider emailing the SML/NJ maintainers and see if they have suggestions on how to discover that information.
In any case, these libraries basically never change—you could download the SML/NJ repo, copy the sig files from there, and include them in Millet's installation. Sorbet does something similar for the Ruby standard library.
something like .d.sml (like .d.ts for typescript) or .smli (like .rbi for sorbet) for writing “interface files” for 3rd party deps
Isn't this already what signature files are? Is there a need to duplicate that? Especially if you already have a system that is capable of processing *.sml
and *.sig
files, it seems redundant.
ok, i think since the std basis libraries change infrequently we can probably include them here. though i think we’d need a config option for what sml impl you’re using since mlton and smlnj (and others) probably ship with different specific libraries.
Isn't this already what signature files are?
not quite. something i currently do for the std basis library files in tree is not check that a structure expression actually ascribes to a signature. this allows me to “conjure up” a structure that ascribes to a signature. this is handy because it allows me to skip providing definitions that would typecheck, since millet doesn’t actually care about the implementation since it doesn’t run code.
if millet allowed user defined .d.sml files or similar i’d probably have it do something similar.
looks like the sml nj libs are doc'd here: https://www.smlnj.org/doc/smlnj-lib/
i might try to scrape them with something similar to what i did for the sml basis libraries: https://github.com/azdavis/sml-basis
Environment
Steps to reproduce
Expected behavior
no error
Actual behavior
The sources.cm file uses two libraries that ship with SML/NJ: the basis library and the SML/NJ json library.
The CM file declares those dependencies like this: