mirror of
https://github.com/anoma/juvix.git
synced 2024-12-14 08:27:03 +03:00
2c8a364143
- Closes #2060 - Closes #2189 - This pr adds support for the syntax described in #2189. It does not drop support for the old syntax. It is possible to automatically translate juvix files to the new syntax by using the formatter with the `--new-function-syntax` flag. E.g. ``` juvix format --in-place --new-function-syntax ``` # Syntax changes Type signatures follow this pattern: ``` f (a1 : Expr) .. (an : Expr) : Expr ``` where each `ai` is a non-empty list of symbols. Braces are used instead of parentheses when the argument is implicit. Then, we have these variants: 1. Simple body. After the signature we have `:= Expr;`. 2. Clauses. The function signature is followed by a non-empty sequence of clauses. Each clause has the form: ``` | atomPat .. atomPat := Expr ``` # Mutual recursion Now identifiers **do not need to be defined before they are used**, making it possible to define mutually recursive functions/types without any special syntax. There are some exceptions to this. We cannot forward reference a symbol `f` in some statement `s` if between `s` and the definition of `f` there is one of the following statements: 1. Local module 2. Import statement 3. Open statement I think it should be possible to drop the restriction for local modules and import statements |
||
---|---|---|
.. | ||
Positive.hs |