Hacker News new | past | comments | ask | show | jobs | submit login
Millet, a Language Server for SML (azdavis.net)
129 points by todsacerdoti on Aug 18, 2022 | hide | past | favorite | 37 comments



Cool project!

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.


I enjoyed my university learning of SML a lot less than I think I should have done. Coming back to it later I was really impressed.

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!


I also didn't know how to apply the concepts at the time, it seemed more academic than practical, but I had a different level of enjoyment.

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.


Same thing here (but with Ocaml). You come into this intro course as someone who can already program and it feels like such a weird take that they deliberately steer you away from playing around and building something cool. IO being important is a hill I'm willing to die on, at least for certain kinds of learners.


Steering me away from bad habits or towards more computer science did make sense - but, yes, actively discouraging me from building things I found cool didn't help my motivation.

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 bricklayer IDE and bricklayer-lite are SML IDEs FWIU [1]. Could Millet and/or three Millet VSCode extension and/or the SML/NJ Jupyter kernel [2] be useful for creating executable books [3][4] for learning?

[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),)


sml was the only one that shadowed lisp in my heart


Well! This is interesting. I like the write-up.

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?


It’s a group of mostly current/former CMU 15-150 TAs working on various SML tools, like:

https://github.com/brandonspark/mulligan

https://github.com/T-Brick/molasses

https://github.com/shwestrick/parse-sml


This is awesome, I will be installing and trying out later today!

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.

[1] https://github.com/SomewhatML/sml-compiler


SML comes with many implementations/compilers, but it is one standardized language (with formalized and verified semantics, IIRC).

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.)?


> it is one standardized language (with formalized and verified semantics, IIRC).

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


I think there was something like a package manager.

Tbh, I wish we lived in an alternative reality where SML won over JS and we had it running on every major browser.


SML can run in every major browser: http://www.smlserver.org/smltojs/

Interestingly, SMLtoJs predates Elm and PureScript, but never really caught on.


A great achievement, but I think that's still running JS in the browser, not SML. Compiling to JS, to be able to run in the browser is not the same as the browsers natively supporting SML code.


Looks cool. Do you know if this ever escaped the lab and got used for anything interesting by people other than its creators?




Author here, hope you like it!


You're reusing some components from rust-analyzer, so is there any reason you didn't go with a more query-based/demand-driven architecture, e.g. by also using salsa?


Just to make the MVP simpler.

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...


>> 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.

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.)

[1] https://dl.acm.org/doi/10.1145/237721.237728


Sounds like they are making salsa easier to adopt

https://smallcultfollowing.com/babysteps/blog/2022/08/18/com...


This is great. I wanted to create something like this for quite some time! I definitely try it.

Well done!


A great language in need of a bit of tooling love. This is awesome!!


Awesome. I would have loved to have had this when I learned SML by running through Okasaki's "Purely Functional Datastructures".

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.


I had a similar experience with “ Modern Compiler Implementation in ML”… but I didn’t slog through it, I switched to ocaml and ported everything as I went. I’m sure an LSP would have been helpful.

https://www.cs.princeton.edu/~appel/modern/ml


Very cool!

Is anyone using SML these days for major projects? Feels like all the hype is around F# and OCaml.


I was introduced to SML in 1996. It has always been a very interesting language, but it never seemed to make it out of academia, which I guess is okay. It seems to have a very nice niche there.


It's at least still used where it originated in proof systems, like Isabelle (as used, for example, in hardware verification work like https://www.lightbluetouchpaper.org/2022/07/22/formal-cheri/ for indirect industrial relevance).


This is awesome!

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.


Wow! This already seems better than F# support in full Visual Studio is.


By the way, the word "Millet" means "people" in Turkish


Hoping Millet doesn't mean anything offensive in any language… Studio Ghibli had this problem mildly with their film "Laputa" ("la puta" = "the whore" in Spanish).


That name actually was an homage to Gulliver's Travels, where it was intentional.


ojalá que laputa no los haya embarazado!


I can't wait to try this out. Thanks for building this!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: