Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pointfreeco/swift-parsing
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: coenttb/pointfree-parsing
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Jan 10, 2025

  1. Removes the restriction on the amount of non-void Parsers that can be…

    … used in a Parserbuilder.
    
    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.
    coenttb committed Jan 10, 2025
    Configuration menu
    Copy the full SHA
    7b6585d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9e22e9e View commit details
    Browse the repository at this point in the history
Loading