I have a different spin from @Kleidukos: My interpretation is that let
can be used anywhere an expression is used. So we can say blurt y = let x = 5 in frob (x + x + y)
or blurt y = frob (let x = 5 in x + x + y)
or even blurt y = frob ((let x = 5 in x) + (let x = 5 in x) + y)
. This is what "let
is an expression" means: it’s part of the recursive structure of expressions. On the other hand, where
is part of a few regimented bits of syntax (a.k.a. “syntactic constructs”), including function/variable equations (which have an =
in them) and case
alternatives. But you can’t put where
anywhere else!
Maybe it’s also helpful to say that “syntactic construct” is a very general term just meaning “bit of syntax”, while “expression” is a specific term referring to the part of a Haskell program that happens, for example, after the =
in blurt x =
. So an expression is a syntactic construct, but not every syntactic construct is an expression. I don’t connect “syntactic construct” with “syntactic sugar”.
I hope this is helpful!