10 ms·
An Anecdote About ML Type Inference (1994)
- cannam 6y agoJust checked the code examples in a current Standard ML compiler, and they work without modification and behave as described. That's why you should choose Standard ML for your next project. Great example though. When looking at Idris I had the impression there was a logical end point of having the type system so descriptive that, given the type of a function, there was only one possible implementation.
- cmrdporcupine 6y agoAbout twenty years ago I endeavored to learn both Standard ML and OCaml, and I found I preferred SML. I'm not clear how OCaml has gotten more mindshare, but I really liked SML/NJ. I suppose back then we were still in the throes of "object-oriented is best" and the "object" in OCaml had some pull
- msla 6y agoIt's also really easy to translate them into Haskell.
- vslira 6y agoPeople compare type checkers with guard rails. In this regard, programming in SML is more like taking the subway :)
- iammiles 6y agoI was introduced to SML via Dan Grossman's Programming Languages course [0] and it's quickly become my favorite programming language to work through problems and brain-teasers. Shame there isn't more non-academic support for it. [0] - https://www.coursera.org/learn/programming-languages https://www.coursera.org/learn/programming-languages
- bmitc 6y agoThat is such a good course. I really enjoyed it and need to go back and finish the third part with Ruby. If you like SML, check out F#. I did part one of that course in SML, F#, Typed Racket, and Scala. F# was by far the cleanest and most concise for each homework assignment. (Most code was written in SML first and then ported to the other languages.) F# has become my side-project language.
- hellodanylo 6y agoI keep getting tricked by ML referring to either the programming language or the subfield of AI.
- shmageggy 6y agoIt used to be that "type inference" would successfully disambiguate, but now things like these exist https://arxiv.org/abs/2005.02161 https://arxiv.org/abs/2005.02161 https://arxiv.org/abs/2004.10657 https://arxiv.org/abs/2004.10657
- perthmad 6y agoThe phenomenon described in this article is actually an instance of Reynold's parametricity. This one of the free stuff you get for using a (reasonable version of) static typing.
- dybber 6y agoPlay with Standard ML in your browser: http://try.mosml.org/ http://try.mosml.org/ There's also an SML compiler generating Javascript: http://www.smlserver.org/smltojs/ http://www.smlserver.org/smltojs/ Just as a simple demo, I combined it with Processing, to make this little thing: http://hjemmesider.diku.dk/~dybber/processing-sml/ http://hjemmesider.diku.dk/~dybber/processing-sml/
- fizixer 6y ago- SML is old - OCaML has OO cruft and OCaML folks themselves keep telling you "Oh, you don't have to use the OO parts of OCaML" Well then effin give me an ML that's more modern than SML, and has no OO cruft! don't tell me "take this stuff that we think is good, and just ignore parts of it that are bad" (and I'm not interested in Haskell). edit: Matt Might lists only two other languages [0], Scala and Scheme. Both are not ML (though I think some folks think Scala is an ML?) [0] http://matt.might.net/articles/best-programming-languages/ http://matt.might.net/articles/best-programming-languages/
- dybber 6y agoWhat is the problem with being old? I see the main problem with SML as lack of libraries and community.
- fizixer 6y agoI guess SML would be it then. I'm sick and tired of the OCaML community that tells you to use OCaML, as if it's better than SML, but then tells you not to worry about the OO parts.
- Benjmhart 6y agoPurescript is Haskell without cruft and built for the web era. Idris or agda for type level goodies.
- hajile 6y agoFrom a language standpoint, there are only a handful of features I would really like. * something like JS backtick interpolation. Strings are hugely important in day-to-day coding for a lot of domains. Baked-in utf8 and Rune (utf32) would also be nice to have. * Leading pipe in cases and `| foo | bar => expr` (maybe guards too, but they can be subject to abuse) * Module Typeclasses which make it harder to create typeclasses everywhere like Haskell, but also does away with some ambiguities and the special case `eqtype` typeclass. SML has a way to add operators, but without typeclasses, it's pretty useless and unsafe. While we're improving modules, bake higher-order functors into them (they are already widely supported) * Bake Concurrent ML into the official spec As you can see, not too many things. In fact, about half of them (or more) are already supported in some SML implementations. Honestly, all the "new" syntax/features in languages like Java, Swift, or C# just seem like attempts to kluge them one step closer to SML.
- Animats 6y agoThis is a good argument for having argument types declared for functions and structures, but inferring as much else as possible. The trouble with inferring everything is someone reading the functions has no idea what the restrictions are. The classic Python example involves "lists" (built-in arrays) vs NumPy arrays. They implement most of the same operators and functions, but with different semantics. For built-in arrays, "+" means concatenate.