leostera / caramel

:candy: a functional language for building type-safe, scalable, and maintainable applications
https://caramel.run
Apache License 2.0
1.05k stars 25 forks source link

feat(compiler): support expression sequences #80

Closed michallepicki closed 3 years ago

michallepicki commented 3 years ago

OCaml represents expression sequences as a (this, next) expression tuple, where there is no difference in representation of (a ; b ; c) vs (a ; (b ; c)). So we're translating this representation to a simpler Expr_seq expr list in the Erlang AST. When the expression sequence is present directly inside an Erlang function case definition, the expresison sequence doesn't need to be wrapped in a begin end block when pretty printing.

closes #59

Also, compile nested let expressions to expression sequences (relates to #68 ). This is a work in progress - will require generating unique names for variables to avoid scoping issues in Erlang.

michallepicki commented 3 years ago

@ostera I think this works pretty well now! Erlang doesn't need the begin/end wrappers when the sequence is directly the body of a function. Do you want me to handle that special case somewhere or are we fine with those additional begin/end in function definitions?

michallepicki commented 3 years ago

@ostera I went ahead and implemented the change mentioned above. I think this is ready for review now!

michallepicki commented 3 years ago

This doesn't add support for parsing begin/end expression sequences in the erlang library, if it needs such feature, I am not familiar with that part of the codebase yet