sdiehl / write-you-a-haskell

Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

poly: more parsing quirks

chsievers opened this issue · comments

  • The outermost expression can't be a let expression:
Poly> let x=0 in x
"<stdin>" (line 1, column 11):
unexpected reserved word "in"
expecting letter or digit
  • Unlike let declarations, let expressions don't allow function definitions with arguments:
Poly> (let f x = x in f 0)
"<stdin>" (line 1, column 8):
unexpected "x"
expecting "="
  • let rec expressions aren't recursive:
Poly> (let rec x = x in x)
Not in scope: "x"
  • Since fix is a special syntactic form that has to be applied to an expression, I expected g fix x not to parse. Instead, it is parsed as g (fix x).