
CakeML – A Verified Implementation of ML - tosh
https://cakeml.org/
======
frou_dh
The example implementation of Unix cat(1) is... intimidating!

[https://github.com/CakeML/cakeml/blob/master/examples/iocatP...](https://github.com/CakeML/cakeml/blob/master/examples/iocatProgScript.sml)

~~~
trurl
It is possible I am misunderstanding something, but I am pretty sure that is
not cat(1) implemented in CakeML. It is an implementation of cat(1) verified
using the same HOL libraries, tactics, etc. that they used to verify the
implementation of CakeML. I didn't look closely enough to see if they have
gone all the way and reimplemented HOL inside of CakeML.

~~~
Gajurgensen
If I recall correctly, most CakeML code is actually written in HOL4 and then
translated down to CakeML, and compiled to machine code from there.
Unfortunately there isn't very much in the way of documentation or examples
for writing concrete CakeML, as the developers seem to use it more as an
intermediate representation.

Edit: The page describes two frontends. The first is a "proof-producing
synthesis" of a CakeML AST from "ML-like functions in HOL". This is what I
believe is the more typical use case of CakeML. The second frontend is a more
traditional frontend which parse concrete CakeML syntax.

------
varshithr
Where do people usually use Standard ML type languages? What are these most
suitable for? (Please excuse me for a lame question. I am an amateur.)

~~~
cannam
Whenever this comes up, the answer seems to be "for programming language
research and proofs in academia" and not much else.

It's a pity. SML is in many ways a joy to work with. The language doesn't
change, which is a nice thing in itself in the current climate, but it has
many things people still look for in modern languages (type inference, pattern
matching, a module system). Multiple compliant compilers are available that
produce fast code. The syntax is delightful, relying on neither brace
delimiters nor syntactic whitespace. The language and Basis library are small
enough that a developer can realistically aim to learn the whole thing. It is
a comfortably idiomatic general-purpose functional language: lacking object or
procedural syntax but relaxed about side-effects and occasional use of mutable
types.

There are problems. Everyone will have their own list of things they expect a
language to have, that SML lacks (mine: a map container in the standard
library; record updating without rebinding all the elements individually;
universal printf/toString, no matter how hacky). There is no standard foreign-
function interface for calling native libraries, and no standard memory model
- each compiler has its own. There is no standard build system (though I
dunno, maybe this is a good thing). Libraries are sorely lacking, although
those written many years ago usually still work. Because the language is a
stem for academic developments, there are several variations that are
intriguing but not actually compatible - CakeML seems to be an example, as it
doesn't support functors or records.

I find SML pretty nice for writing small command-line utilities - like a
functional alternative to Go or Python.

~~~
jcelerier
> It's a pity. SML is in many ways a joy to work with. The language doesn't
> change, which is a nice thing in itself in the current climate, but it has
> many things people still look for in modern languages (type inference,
> pattern matching, a module system). Multiple compliant compilers are
> available that produce fast code. The syntax is delightful, relying on
> neither brace delimiters nor syntactic whitespace.

is it now ? Caml has been taught for a long time to a lot of to-be engineering
students in france, and it was frankly almost universally hated ; likewise for
people that are taught LISP.

~~~
cannam
> is it now ?

Well of course I think so, since I said it... But -

> Caml has been taught for a long time to a lot of to-be engineering students
> in france, and it was frankly almost universally hated

It's possible to wonder why a language like SML doesn't get more use outside
academia, since so many people have been taught it as students. And it seems a
reasonable explanation that many people who were taught these languages simply
disliked the experience. If you're forced to learn a weird non-procedural
language with no obvious application and a super-picky type checker that you
can't understand, why would you like it?

I had a vaguely similar experience myself, when taught SML as a student in the
90s. I enjoyed it as an exercise, but by the end of the course I still didn't
have any useful intuition for how to write a whole program in it. Meanwhile
over on the C++ course, the object/procedural mix seemed to make more obvious
sense as a way to structure things.

Now, after years working in C++, I think of SML as the easier language and in
many ways more natural.

------
pinewurst
Online SML (SMLNJ):
[https://www.tutorialspoint.com/execute_smlnj_online.php](https://www.tutorialspoint.com/execute_smlnj_online.php)

I really liked SMLNJ plus there's MLTON which is a highly optimizing SML
compiler, albeit not so friendly with error messages (or it wasn't when I used
it).

