feat(fanout): variadic composition + fanout(keypaths:into:) - #100
Merged
Conversation
…rg composition
Bridge the SE-0110 gap between a fanout's tuple and a multi-argument
initializer, so narrowing a large value into a smaller one whose init
takes the parts as separate arguments is point-free:
fanout(\.badge, \.save) >>> Env.init // operator
fanout(keypaths: \.badge, \.save, into: Env.init) // symbol-free
- Add variadic `>>>`/`<<<` overloads composing `(Root) -> (repeat each T)`
with `(repeat each T) -> Out`; coexist with the single-arg overloads
without ambiguity.
- Add `fanout(keypaths:into:)` — key paths (constrained to Sendable) fanned
straight into a multi-arg function, no intermediate tuple spelled out.
- Make the existing `fanout(_:)` return `@Sendable`.
- Tests (FanoutTests + variadic composition cases) and docs (README, DocC).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E7QbufqFGENZXn4RwDPS6x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two point-free ways to fan a value out over several accessors and feed the pieces straight into a multi-argument function (typically a memberwise
init): a variadic>>>/<<<overload, andfanout(keypaths:into:).Why
Narrowing a large value into a smaller one whose
inittakes the parts as separate arguments — e.g. deriving a feature'sEnvironmentfrom a bigWorld— is a constant shape. Plainfanout(…) >>> Env.initcan't type-check because Swift (SE-0110) treats a tuple argument and a multi-argument parameter list as distinct types. A variadic overload of>>>bridges the two; for callers who'd rather avoid the operator,fanout(keypaths:into:)closes the loop in one call.The variadic
>>>coexists with the single-argument overload without ambiguity (single-output → plain overload, tuple-output → variadic).Changes
CoreFPOperators/Function/FunctionComposition.swift— add variadic>>>/<<<overloads composing(Root) -> (repeat each T)with(repeat each T) -> Out.CoreFP/Utilities/Fanout.swift— addfanout(keypaths:into:)(key paths constrained toSendable); make the existingfanout(_:)return@Sendable.FanoutTests(new) + variadic composition cases inFunctionCompositionTests.PointFreeStyle+CoreFPOperatorsarticles.Full suite green (2775 tests); swiftlint --strict clean on changed files.
🤖 Generated with Claude Code