| @@ -16,18 +16,23 @@ OCaml, Haskell and F# show the alternative: definitions and calls by juxtapositi |
| 16 | 16 | |
| 17 | 17 | ### Definitions |
| 18 | 18 | |
| 19 | | −Parameters become space-separated patterns; the parentheses go: |
| 19 | +Parameters become space-separated patterns; the parentheses go. A `::` |
| 20 | +separates the name from the parameters — without it, the name and the |
| 21 | +first parameter run together for the reader and the parser alike |
| 22 | +(`fn insert ~into: ..` reads as one word too many): |
| 20 | 23 | |
| 21 | 24 | ```text |
| 22 | | −fn add a b { a + b } |
| 25 | +fn add :: a b { a + b } |
| 23 | 26 | |
| 24 | | −fn on_message (State(..) as state) msg -> Next<State> / <store_fx> { .. } |
| 27 | +fn on_message :: (State(..) as state) msg -> Next<State> / <store_fx> { .. } |
| 25 | 28 | |
| 26 | | −fn k_integrate ~weight:(f: fn(Float, Bool) -> Float / <ffi>) from: Float to: Float |
| 29 | +fn insert :: ~into:(table: String) ~key:(k: String) value: String -> () / <io> |
| 30 | + |
| 31 | +fn k_integrate :: ~weight:(f: fn(Float, Bool) -> Float / <ffi>) from: Float to: Float |
| 27 | 32 | -> Float / <ffi> { .. } |
| 28 | 33 | ``` |
| 29 | 34 | |
| 30 | | −A parameter is a pattern (as today) with an optional `: T`; parentheses are needed only to group a pattern. Lambdas, effect operations, handler clauses, trait and impl methods share the shape: `fn log (msg: String) -> ()`, `log m -> resume(m)`, `fn first c { .. }`. A `fn` with no parameters is `fn main { .. }` — and `main` the *value* is the same name, so `fn f` in signature position is the zero-parameter function (its type is `fn() -> T`; see §Types). |
| 35 | +A parameter is a pattern (as today) with an optional `: T`; parentheses are needed only to group a pattern. Effect operations and trait and impl methods share the shape: `fn log :: (msg: String) -> ()`, `fn first :: c { .. }`. Handler clauses are not definitions and keep theirs: `log m -> resume(m)`. Lambdas have no name, hence no `::`: `fn x { x + 1 }`. A `fn` with no parameters is `fn main :: { .. }` — and `main` the *value* is the same name, so `fn f ::` in signature position is the zero-parameter function (its type is `fn() -> T`; see §Types). |
| 31 | 36 | |
| 32 | 37 | ### Application |
| 33 | 38 | |
| @@ -122,6 +127,5 @@ The compiler's own parse of std keeps `louise check` honest at every step; the U |
| 122 | 127 | ## Open for review |
| 123 | 128 | |
| 124 | 129 | - The indentation rule's exact statement (what counts as "the statement's indent" inside match arms, handler clauses and `use` bodies), and its tree-sitter scanner twin. |
| 125 | | −- Whether `fn f` with zero parameters and `f` the value read well enough, or zero-parameter definitions keep `fn f()`. |
| 126 | 130 | - `~` in constructor patterns and record update, or `:` kept there as construction-not-application. |
| 127 | 131 | - The migration tool's fidelity on comments and hand formatting (it owes a token check, like the formatter's). |