by jcelerier · 6y ago · 0 comments
do
x <- a
y <- b
return (f x y)
isn't basically imperative syntax ?
hint: if you can get from it to C (or pascal or python or whatever) simply by adding a couple types, semicolons and replacing operators, it's C. let x = a
y = b
in (f x y)
? Which in turn is very much like OCaml syntax or plenty of other functional syntaxes.This could be doing any one of:
- flatmapping over lists
- doing a computation with Maybe types, producing Nothing if a or b are nothing
- doing IO
- managing futures
- pretty much anything, actually
Don't confuse 'x <- a' with assignment, or 'return' with returning a value.
Another way of looking at it, (f x y) might be invoked:
- once
- never
- more than once
- later
hint: you are wrong.
It isn't "almost C-like syntax", unless you define that to mean "if I do any amount of search and replace I can make it into valid C code that has completely different semantics". "x <- a" in haskell is not at all the same as "x = a" in C.
And that isn't the reason I said your comment is wrong. Your comment is wrong because do notation is not the result of "40 years of research in functional PL", nor is it an accomplishment. It is simple syntactic sugar that didn't come from research at all.
Your comment could be accurately summarized as "I would like to express how smug I feel for not learning something".
are you kidding me ? if a 2016 paper from Simon Peyton Jones isn't research then what is ? (https://dl.acm.org/doi/pdf/10.1145/3241625.2976007)
But your chuckle has shown me that this code is just plain old C, with links to documents you haven't even read. Thank you for enlightening me, great chuckler.