diff options
| author | tslil <tslil@posteo.de> | 2025-10-18 22:54:24 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2025-10-18 23:52:52 +0100 |
| commit | 5cf06bab8d5a8c6115df35f6cec652bfd0fd0922 (patch) | |
| tree | ca412a1f1c0b58f464bb9f5583e028d403e9e63b /rprt.md | |
| parent | 16f0479a4e43a58c04796e9aa4d43d92b2655024 (diff) | |
Parse hooks, these are left associative
Diffstat (limited to 'rprt.md')
| -rw-r--r-- | rprt.md | 16 |
1 files changed, 9 insertions, 7 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. +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`. ## 1.3 The Editor State Monad @@ -144,8 +144,10 @@ The grouping operator `{}` provides transactional semantics: all operations with # 1.7 Composition and Parsing -**Precedence:** Following BQN rules: -- Operators bind tighter than functions +**Precedence and Associativity:** Following BQN rules: +- 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)` - Functions and operators apply left-to-right - Dyadic functions are infix @@ -374,12 +376,12 @@ Text operations follow the broadcasting rules described in §1.2. When the text **Examples:** ``` -| "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) +| "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) ``` -The third example composes two After hooks (§1.2): `|<"sort"` creates a monadic selection 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")`, avoiding explicit repetition of the selection. Note the parentheses are necessary: `c<|<"sort"` would incorrectly parse as `α c (| "sort")`, 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 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. ## 3.2 Text Function Operators |
