Skip to content

Commit 54cfaa1

Browse files
Technologicatclaude
andcommitted
monadic_do docs: drop the "own with" note — nested is the default idiom
Block macros all typically use nested `with` blocks anyway, so the special-case callout was unnecessary noise. Removed from the monadic_do module docstring and the brief. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 65abdf3 commit 54cfaa1

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

briefs/monads-implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The "innermost" position is both *forced* (by body shape) and *correct* (edit or
141141

142142
- **Correct**: two-pass macros (`lazify`, `tco`, `continuations`, `autocurry`, `envify`, `namedlambda`, `autoref`) do their first pass, then explicitly expand inner macros via `dyn._macro_expander.visit_recursively(body)`, then their second pass. `monadic_do` (one-pass outside-in) fires during the outer macro's `visit_recursively`, producing the bind chain. The outer macro's second pass then edits the expanded chain — exactly the order we want (autocurry curries the calls, lazify force-wraps references, tco optimizes tails, CPS transforms for continuations). One-pass outside-in surface-syntax macros (`prefix`, `autoreturn`, `quicklambda`, `multilambda`) normalize their body before descending, so `monadic_do` sees normal Python when it fires.
143143

144-
**Always in its own nested `with`** — unlike the other xmas-tree macros which chain in one `with` for brevity, `monadic_do(M) as result` has both an argument and an `as` binding, making same-`with` chaining syntactically awkward. Call this out explicitly in the macro's docstring.
144+
Usage is just the ordinary nested-`with` style that all block macros typically use — no special "must be own `with`" rule needed.
145145

146146
**Dialects**: the same analysis applies transparently. Dialects (e.g., Lispython) wrap a module in block macros at parse-assembly time; `monadic_do` sits innermost within whatever the dialect adds. No dialect-specific integration testing is prioritized — the generic integration tests cover the same underlying macros.
147147

unpythonic/syntax/monadic_do.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333
``continuations``, ``tco``, ``autocurry``, etc.) expand inner macros
3434
between their two passes, which means they will correctly see and edit
3535
the expanded bind chain.
36-
37-
**Always in its own nested ``with``** — unlike the other xmas-tree
38-
macros which chain in one ``with`` for brevity, ``monadic_do[M] as result``
39-
has both a macro argument and an as-binding, and same-``with`` chaining
40-
with that combo is syntactically fragile.
4136
"""
4237

4338
__all__ = ["monadic_do"]

0 commit comments

Comments
 (0)