Syntax Error on "in"

OCaml has two different forms of let syntax. We can think of them as ‘let statement’ and ‘let expression’.

‘Let statement’ has the form let PAT = EXP and can exist at the module level only. Module level is directly inside a module. I.e. in a file or in a syntactic module.

‘Let expression’ has the form let PAT = EXP1 in EXP2 and can exist at the expression level only. Expression level is anything on the right-hand side of the equal sign in let ... = ....

4 Likes