Millet, a Language Server for SML
azdavis.net
azdavis.net
I always thought SML was a great language for teaching computer science and functional programming.
A lot more fun than learning Java. With ML, you got glimpses of aesthetic beauty in code.
[1] https://bricklayer.org/level-1/ :
> Bricklayer libraries provide support for creating 2D and 3D block-based artifacts. Problem-solving and math are used to exercise creative and artistic skills in a fun and innovative environment. Bricklayer integrates with third-party software including: LEGO Digital Designer, LDraw, Minecraft, and 3D Builder (LeoCAD; `dnf install -y leocad`)
[2] https://github.com/matsubara0507/simple-ismlnj
[3] https://github.com/executablebooks
[4] https://executablebooks.org/en/latest/ (Jupyter-Book: Sphinx (Docutils (.rst ReStructuredText), .md)), MyST-Parser (.md MyST Markdown), Jupyter Kernels (.ipynb Jupyter Notebooks),)
Before university I'd programmed (primarily in BASIC) for many years, so imperative programming just made sense to me. Functional programming seemed alien and the amazing type system of ML-like languages just seemed to get in my way.
What I was missing was the context to understand why it was good. And, to be honest, some compelling examples - we almost completely glossed over IO and system interfaces and the gyrations required to do things like efficient iteration just seemed a bit pointless.
It was good computer science but I found it to be very unsatisfying engineering as I couldn't see how to build something useful. This may be my fault for not doing an engineering degree ;-)
Once I understood more of how these systems are built at lower levels I was much better equipped to be impressed by how much of that was hidden from view!
Having been a script kiddie teenager, just hacking together stuff that worked, functional programming seemed like some beautiful alien artifact.
I didn't really understand it, but it seemed elegant and enigmatic, which made me want to learn more.
It didn't deter everybody, though - my friend went full speed ahead and implemented a graphical MacOS application using SML that forwarded e-mails over SMS so he could read them on his phone.
I was amazed to discover that was possible!
The acknowledgements include "Project Savanna, a group who shares my desire in improving the tooling around SML", with a link to a Slack page that asks for a login. Can you say anything more about this project?
https://github.com/brandonspark/mulligan
I was working on a SML compiler [1] and language server in Rust as well, but I dropped the ball towards the end of 2020 as I had a PhD to finish!
SML is a great language, and I think some better tooling (like a language server) is all that it really needs to be useful.
Does that mean that there is one repository with modules (like PyPI or Maven Central) which all the implementations can use? Is there even a single build tool that can work with all (or at least some) of them (like Maven, etc.)?
Tbh, I wish we lived in an alternative reality where SML won over JS and we had it running on every major browser.
Interestingly, SMLtoJs predates Elm and PureScript, but never really caught on.
Unfortunately the spec defines too little, and there are large deviations between implementations. See
http://mlton.org/StandardMLPortability
http://mlton.org/UnresolvedBugs
http://mlton.org/SMLNJDeviations
SML/NJ is the most used implementation afaik. mlton is a whole-program optimizing compiler
Well done!
I note in the caveats that the current approach is to recompute everything whenever even one file is changed. But that’s probably not sustainable, as I admit myself in https://azdavis.net/posts/pl-idea-tooling/ :
> As an example, it would be unsustainable if, every time we changed a single function’s body, the language server had to re-typecheck the entire codebase. This might work for an initial proof-of-concept on a small codebase, but for large ones, the responsiveness of the language server would drop precipitously.
If I get around to addressing this, I’d probably use salsa and/or follow along this post: https://rust-analyzer.github.io//blog/2020/07/20/three-archi...
https://smallcultfollowing.com/babysteps/blog/2022/08/18/com...
If only there were a type system[1] where you could reinfer the function’s type in isolation and then recheck all uses!
(I don’t think Trevor Jim’s work on System P2 and System P received any further development, even in “better SML” work like 1ML, which seems like a shame, so I’m going to shill it wherever it appears relevant.)
The type system and compiler eventually beat me into submission, but an LSP would have probably eased me into it.
I highly recommend that book by the way.
Is anyone using SML these days for major projects? Feels like all the hype is around F# and OCaml.
I love the syntax of SML and found the examples of it I've seen online to "click" for me, which isn't the case with OCaml (ugly syntax) and Haskell (can't read it).
Always was a bummer that SML was a sort of dead-end language without a good tooling story.