From 2d088bbe29626c26dba0c1d0290c16c1df7f16b8 Mon Sep 17 00:00:00 2001 From: tslil Date: Sun, 22 Mar 2026 15:40:16 +0000 Subject: fix text function documentation to correctly reflect left-assoc --- rprt.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'rprt.md') diff --git a/rprt.md b/rprt.md index 769df6c..9878bf9 100644 --- a/rprt.md +++ b/rprt.md @@ -25,7 +25,7 @@ All functions work with two core types: A **Selection function** is something of signature `Selection × Selection → Selection`. -A **Text function** is something of signature `Selection × Text → Selection`. +A **Text function** is something of signature `Text × Selection → Selection`. Following APL conventions, functions may have nullary, monadic, and dyadic forms. In these cases the number of arguments that they take varies (though not their types). @@ -353,7 +353,7 @@ The key distinction is when the complement is applied: `~?F` complements the con ## 3.1 Text Operations -Text operations have signature `Selection × Text → Selection`. They modify the editor state (buffer contents) and return the affected Selection. +Text operations have signature `Text × Selection → Selection`. They modify the editor state (buffer contents) and return the affected Selection. Text operations follow the broadcasting rules described in §1.2. When the text argument `τ` is itself a Selection that coerces to Text, the text values are paired with ranges following the buffer-first, then range-within-buffer ordering (the leading axis). @@ -371,36 +371,36 @@ Text operations follow the broadcasting rules described in §1.2. When the text | Function | Effect | Return selection | |----------|--------------------------------------------------|---------------------------------------------| -| `. τ` | No-op | Current selection in buffers named by `τ` | -| `c τ` | No-op | Replace the current selection by `τ` | -| `i τ` | No-op | Insert `τ` into the current selection | -| `a τ` | No-op | Append `τ` to the current selection | -| `d τ` | Delete current selection in buffers named by `τ` | Empty selection in buffers named by `τ` | -| `w τ` | Write the buffers named by `τ`. | Current selection in buffers named by `τ` | -| `\| τ` | Run `τ` | Return selection of ephemeral buffer output | +| `τ .` | No-op | Current selection in buffers named by `τ` | +| `τ c` | No-op | Replace the current selection by `τ` | +| `τ i` | No-op | Insert `τ` into the current selection | +| `τ a` | No-op | Append `τ` to the current selection | +| `τ d` | Delete current selection in buffers named by `τ` | Empty selection in buffers named by `τ` | +| `τ w` | Write the buffers named by `τ`. | Current selection in buffers named by `τ` | +| `τ \|` | Run `τ` | Return selection of ephemeral buffer output | **Note:** The text argument `τ` may be a string literal or a Selection (which coerces to Text). **Note:** `\|` and `d` are undefined when the rank of `τ` is 0. | Function | Effect | Semantics | |----------|------------------------------------------------------|-----------------------------------------------------------| -| `α . τ` | No-op | Current selection in buffer(s) named by `τ` (`α` ignored) | -| `α c τ` | No-op | Change (replace) `α` with text `τ` | -| `α i τ` | No-op | Insert text `τ` before `α` | -| `α a τ` | No-op | Append text `τ` after `α` | -| `α d τ` | Delete `α` in buffers named by `τ` | Empty selection in buffers nameb by `τ` | -| `α w τ` | Write (concatenation of) `α` in buffers named by `τ` | `α` | -| `α \| τ` | Pipe `α` through command `τ` | Return selection of ephemeral output buffer | +| `τ . α` | No-op | Current selection in buffer(s) named by `τ` (`α` ignored) | +| `τ c α` | No-op | Change (replace) `α` with text `τ` | +| `τ i α` | No-op | Insert text `τ` before `α` | +| `τ a α` | No-op | Append text `τ` after `α` | +| `τ d α` | Delete `α` in buffers named by `τ` | Empty selection in buffers nameb by `τ` | +| `τ w α` | Write (concatenation of) `α` in buffers named by `τ` | `α` | +| `τ \| α` | Pipe `α` through command `τ` | Return selection of ephemeral output buffer | **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 +("date" |) c /pattern/ # Replace pattern with date command output +α ("sort">|)>c # 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 not necessary because hooks are right-associative. +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 `α ("sort">|)>c` expands to `(α ("sort">|)) c α` = `("sort" | α) c α`, avoiding explicit repetition of the selection. Note that parentheses are not necessary because hooks are right-associative. ## 3.2 Text Function Operators @@ -408,21 +408,21 @@ Text function operators modify the behavior of text functions. ### The Swap Operator -The `swap` operator reverses the arguments of a text function, converting `α F τ` into `τ F α`. For this to typecheck both arguments must be selections. +The `swap` operator reverses the arguments of a text function, converting `τ F α` into `α F τ`. For this to type-check both arguments must be selections. **Syntax:** `@ F` -**Semantics:** `α (@ F) τ = τ F α` +**Semantics:** `τ (@ F) α = α F τ` This is particularly useful for composing text operations where the natural argument order needs to be reversed. **Idiom for moving content:** ``` -α {@i , d} β +α {i , d} β ``` Using the swap operator `@`, this evaluates in parallel: -* `α @i β` which is `β i α` which means "insert at (the start of) β the content from α" +* `α i β` which is "insert at (the start of) β the content from α" * `α d β` which means "delete α" The net result of this is to _move_ the content of α to (the start of) the selection given by β. -- cgit v1.2.3