3 ms·
(ETA: speaking strictly about anonymous functions; on rereading you might be talking about the absence of parens and commas for function application.) That's n
by wk_end 2y ago
(ETA: speaking strictly about anonymous functions; on rereading you might be talking about the absence of parens and commas for function application.)
That's not ML syntax. Haskell got it from Miranda, I guess?
In SML you use the `fn` keyword to create an anonymous function; in Ocaml, it's `fun` instead.
- throwaway17_17 2y agoI believe the `\` character for functions is original to Haskell. Miranda does not have anonymous functions as a part of the language.
- pezezin 2y agoThe \ is a simplified lambda, because most programmers can't type λ easily.
- robertlagrant 2y agoI would be very in favour of making λ a keyword, though. Maybe a linter could convert \ to λ.
- iso8859-1 2y agoit would be confusing since it's not part of UnicodeSyntax https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/unicode_syntax.html https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/unic...
- robertlagrant 2y agoWell, even better to add it to that! But I was thinking generally, to be honest. I really want Python to synonimise the keyword lamdba with the λ symbol so I can golf my Advent of Code code better.
- robertlagrant 2y agoArgh. Synonymise.
- needlesslygrim 2y agoWell, ML (or at least the first versions of it) used a λx • x syntax [1] for λ-abstractions, the same (excluding the use of • over .) notation as used with the Lambda Calculus, and I've always assumed \ was an ASCII stand in. [1]: https://homepages.inf.ed.ac.uk/wadler/papers/papers-we-love/milner-type-polymorphism.pdf https://homepages.inf.ed.ac.uk/wadler/papers/papers-we-love/... (can be spotted on page 353)
- wk_end 2y agoThat paper isn't showing real ML syntax itself; it's a mathematical presentation to demonstrate how the type system algorithm works. The actual original LCF/ML syntax would differ. I don't believe it used an actual lambda character, although for the life of me I can't find any evidence one way or another, not even in the LCF source code (https://github.com/theoremprover-museum/LCF77 https://github.com/theoremprover-museum/LCF77) But yes, the slash is just an ASCII stand-in for a lambda. ETA: I tracked down a copy of the Edinburgh LCF text and I have to eat crow. It doesn't use a lambda, but it does use a slash rather than a reserved word. The syntax, per page 22, is in fact, `\x. e`. Similar to Haskell's, but with a dot instead of an arrow. https://archive.org/details/edinburghlcfmech0000gord https://archive.org/details/edinburghlcfmech0000gord
- needlesslygrim 2y agoWell if you're going to eat crow, I may as well eat pigeon, for I didn't realise that paper wasn't showing real source. Thanks for the link to the LCF text though :^)