-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes the restriction on the amount of non-void Parsers that can be…
… used in a Parserbuilder. (#367) This update removes the need for all Take*n overloads except Take2, and is fully backwards compatible. The parameter pack buildblock relies on a new Take2.Map, which is a tradeoff. On the one hand, we'd prefer to use a Conversion and MapConversion here as the elegant solution. However, consider this mock/theoretical TupleConversion: public struct TupleConversion<each T1, T2>: Conversion { public typealias Input = ((repeat each T1), T2) public typealias Output = (repeat each T1, T2) public func apply( input: ((repeat each T1), T2)) -> (repeat each T1, T2) { let (first, second) = input return (repeat each first, second) } public func unapply( output: (repeat each T1, T2)) -> ((repeat each T1), T2) { guard let tuple = output as? ((repeat each T1), T2) else { fatalError("Could not convert output tuple type") } return tuple } } This would require macOS 14, as it uses parameter packs in generics. This is not fully backwards compatible. I therefore am of the opinion that the tradeoff with introducing Take2.Map is worth it, as this approach maintains backwards compatibility, while only adding a little surface area. See also VariadicTests.swift for passing test. Co-authored-by: Stephen Celis <[email protected]>
- Loading branch information
1 parent
95080d0
commit d34ca0b
Showing
2 changed files
with
95 additions
and
311 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.