diff options
Diffstat (limited to 'rprt.md')
| -rw-r--r-- | rprt.md | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -98,7 +98,7 @@ RPRT provides two explicit hook combinators from BQN for flexible function compo - Monadic: `(F<G) ω = ω F (G ω)` - Dyadic: `α (F<G) ω = α F (G ω)` -These combinators bind more tightly than trains and enable partial application patterns. Hooks are **left-associative**, following BQN's modifier associativity: `F<G<H` parses as `(F<G)<H`. +These combinators bind more tightly than trains and enable partial application patterns. Hooks are **right-associative**, the _opposite_ of BQN's modifier associativity: `F<G<H` parses as `F<(G<H)`. ## 1.3 The Editor State Monad @@ -144,13 +144,15 @@ The grouping operator `{}` provides transactional semantics: all operations with # 1.7 Composition and Parsing -**Precedence and Associativity:** Following BQN rules: +**Precedence and Associativity:**: - Hooks bind tighter than trains -- Hooks are left-associative: `F<G<H` = `(F<G)<H` -- Trains are right-associative: `F G H I` = `F (G H I)` +- Hooks are right-associative: `F<G<H` = `F<(G<H)` +- Trains are left-associative: `F G H I` = `(F G) H I` - Functions and operators apply left-to-right - Dyadic functions are infix +Note that the associativity of operations here is _reversed_ compared to BQN. Our reasoning for breaking with this convention is purely for convenience of the user: the monadic semantics for search functions is given on a _left_ argument, which matches the usual order in which expressions are made, "first select this, then using that selection do that, then ...". + # 2. Selection Functions @@ -378,10 +380,10 @@ Text operations follow the broadcasting rules described in §1.2. When the text ``` | "date" # Run date with no input, returns selection to output /pattern/ c (| "date") # Replace pattern with date command output -α c<(|<"sort") # Pipe selection through sort, replace with result (using After hooks) +α c<|<"sort" # Pipe selection through sort, replace with result (using After hooks) ``` -The third example composes two After hooks (§1.2): `|<"sort"` creates a monadic function that pipes its argument through sort, where `"sort"` is treated as a constant Text function (§1.1). Then `α c<(|<"sort")` expands to `α c ((|<"sort") α)` = `α c (α | "sort")`, avoiding explicit repetition of the selection. Note that parentheses are necessary because hooks are left-associative: without them, `c<|<"sort"` would parse as `(c<|)<"sort"`, which expands to `α (c<|) "sort"` = `α c (| "sort")`, incorrectly running sort with no input. +The third example composes two After hooks (§1.2): `|<"sort"` creates a monadic function that pipes its argument through sort, where `"sort"` is treated as a constant Text function (§1.1). Then `α c<|<"sort"` expands to `α c ((|<"sort") α)` = `α c (α | "sort")`, avoiding explicit repetition of the selection. Note that parentheses are not necessary because hooks are right-associative. ## 3.2 Text Function Operators |
