The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
## What's Changed
* Changed: Bump to Case Paths 1.0 (https://github.com/pointfreeco/swift-parsing/pull/306).
* Fixed: Remove unused package dependencies (https://github.com/pointfreeco/swift-parsing/pull/303).
* Fixed: Remove a Swift 5.9 warning (https://github.com/pointfreeco/swift-parsing/pull/304).
* Infrastructure: Improve `Date` parser demo (https://github.com/pointfreeco/swift-parsing/pull/305).
**Full Changelog**: https://github.com/pointfreeco/swift-parsing/compare/0.12.1...0.13.0
## What's Changed
* Fixed: `Formatted` parser now only consumes what it matches, and not the rest of the string (https://github.com/pointfreeco/swift-parsing/pull/301).
* Infrastructure: Fix seconds mapping in Date benchmark (thanks @jacoblapworth, https://github.com/pointfreeco/swift-parsing/pull/295).
## New Contributors
* @jacoblapworth made their first contribution in https://github.com/pointfreeco/swift-parsing/pull/295
**Full Changelog**: https://github.com/pointfreeco/swift-parsing/compare/0.12.0...0.12.1
## What's Changed
> **Warning**: This release contains breaking changes in order to support Swift 5.8's [rewritten result builder implementation](https://forums.swift.org/t/improved-result-builder-implementation-in-swift-5-8/63192). While the package will build for Swift 5.7, we recommend delaying this upgrade till you can use Swift 5.8, as the changes impact compile time performance of `ParserBuilder` and `OneOfBuilder`.
* Added: Swift 5.8 Support (thanks @JaapWijnen, https://github.com/pointfreeco/swift-parsing/pull/289). Note: due to result builder changes in Swift 5.8, code that compiled just fine in Swift 5.7 and Parsing 0.11.0 and earlier may be source incompatible in Swift 5.8 and this Parsing release.
See [this discussion](https://github.com/pointfreeco/swift-parsing/discussions/290) for more details.
* Added: Parsers can now be implemented in the SwiftUI "body" style:
```swift
struct UserParser: Parser {
var body: some Parser<Substring, User> {
Parse(User.init(id:name:isAdmin:)) {
Int.parser()
","
Prefix { $0 != "," }
","
Bool.parser()
}
}
}
```
* Added: A new `Backtrack` parser (https://github.com/pointfreeco/swift-parsing/pull/287). Useful for adding explicit backtracking to a parser.
* Changed: The `CaseIterableRawRepresentable` parser printer has been extended to work with any `FixedWidthInteger` (thanks @ytyubox, https://github.com/pointfreeco/swift-parsing/pull/277).
## New Contributors
* @ytyubox made their first contribution in https://github.com/pointfreeco/swift-parsing/pull/277
**Full Changelog**: https://github.com/pointfreeco/swift-parsing/compare/0.11.0...0.12.0
## What's Changed
- Swift 5.7 Updates (#261)
- Changed: Parsing's builder limitations have been greatly improved. `OneOfBuilder` now takes an unlimited number of parsers, and `ParserBuilder` now takes an unlimited number of `Void` parsers, and up to 10 non-`Void` parsers.
- Changed: Swift 5.7 Improvement: The `Parser`, `ParserPrinter`, `Conversion`, and `PrependableCollection` protocols now have primary associated types.
- Added: `Formatted` parser-printer, for incrementally parsing and printing using Apple's family of formatters.
- Changed: The `End` parser's conditional conformance requiring `Collection` has been broadened to work with any `Sequence` (thanks @JaapWijnen, #250).
- Fixed: The `Prefix` parser-printer could erroneously fail to print when `max` was configured. This has been fixed (thanks @oskarek, #256).
- Removed: The experimental `_URLRouting` module has been removed. Please upgrade to [the official package](https://github.com/pointfreeco/swift-url-routing), instead.
- Infrastructure: Typo fixes (thanks @kamcma, #253; @elfenlaid, #257, #258).
## New Contributors
* @kamcma made their first contribution in https://github.com/pointfreeco/swift-parsing/pull/253
* @elfenlaid made their first contribution in https://github.com/pointfreeco/swift-parsing/pull/257
**Full Changelog**: https://github.com/pointfreeco/swift-parsing/compare/0.10.0...0.11.0
- Added: `StartsWith`, `PrefixThrough`, and `PrefixUpTo` overloads to aid in type inference for substring and UTF-8 parsers (thanks @tgrapperon).
- Changed: Parsing now has Apple platform requirements equivalent to SwiftUI (iOS 13+, macOS 10.15+, tvOS 13+, watchOS 6+). If these minimum requirements don't fit your needs, [let us know](https://github.com/pointfreeco/swift-parsing/discussions/new).
- Fixed: `PipeEnd` now conforms to `ParserPrinter`, fixing printability of piped parsers (thanks @JaapWijnen).
- Deprecated: the `_URLRouting` module is now deprecated. Use the [URL Routing](https://github.com/pointfreeco/swift-url-routing) package instead.
- Removed: `Conversions.Parsing`, which was not reachable through any static member on `Conversion`, and confused some users. If you have a use case motivating this conversion, [let us know](https://github.com/pointfreeco/swift-parsing/discussions/new).
- Fixed: Added a missing `ParserPrinter` conformance to `OptionalOneOf`, which prevented parsers that used `if` statements in `@OneOfBuilder` blocks from being printers.
The following changes have been made to the more experimental `_URLRouting` module:
- Added: A `Body()` initializer that takes no arguments. It simply parses the entire body as `Data`.
- Infrastructure: documentation changes.
- Fixed: A `Double.parser()` overflow bug has been fixed (thanks @tgrapperon).
The following changes have been made to the more experimental `_URLRouting` module:
- Added: A `URLRoutingClient` for wrapping a router and URL session into an HTTP client.
- Fixed: A few potential bugs around `Field` and `Body` being empty.
Introduced the `ParserPrinter` protocol for invertible parsing.
- Added: A case-iterable, raw-representable parser. Simply tack `.parser()` onto any conforming type:
```swift
enum Role: String, CaseIterable {
case admin
case guest
case member
}
try Role.parser().parse("admin") // Role.admin
```
- Fixed: An Xcode 13.3 compiler error has been fixed.
- Fixed: `Optionally` will now backtrack if the parser fails (thanks @randomeizer).
- Fixed: `Double.parser()` now parses as freely as `Double.init`'s `LosslessStringConvertible` functionality.
- Optimized: `Peek` and `Not` will only backtrack when they are successful (_i.e._, if `Peek`'s upstream parser successfully parses a value, or if `Not`'s upstream parser fails to parse a value). Backtracking on failure is now delegated to any upstream `OneOf`s.
- Optimized: `OneOfMany` no longer backtracks its final failure, bringing it in line with the behavior of the variadic `OneOf`s.
- Breaking change: The non-`inout` overloads of `Parser.parse` now attempt to fully consume `Collection`-based inputs.
```swift
// Before:
try Int.parser().parse("42hello") // 42
// After:
try Int.parser().parse("42hello")
// error: unexpected input
// --> input:1:13
// 1 | 42hello
// | ^ expected end of input
```
This change makes parsing a bit more strict by default in order to catch potential issues with input.
If you want to ignore trailing output, use the `inout` version of `parse`, or explicitly describe how the input should be ignored in the parser, for example using `Optionally { Rest() }.map { _ in () }`.
- Breaking change: The `Rest` parser now fails when the rest of input is empty.
```swift
// Before:
try Rest().parse("") // ""
// After:
try Rest().parse("")
/// error: unexpected input
/// --> input:1:1
/// 1 |
/// | ^ expected a non-empty input
```
If your use of `Rest` should not fail on empty input, wrap it explicitly in an `Optionally` parser, or use `replaceError(with:)` to provide a default value of `""`.
- Breaking change: `Peek` is now a `Void` parser. It can be used to inspect a value in order to test that a parser should be successful, but capturing any data is now the responsible for the parsers that comes afterward (thanks @randomeizer).
- Breaking change: The `isSigned` parameter of `Int.parser()` has been removed. `Int.parser()` will now always parse a sign if `FixedWidthInteger.isSigned` returns true (_e.g._, `Int.parser()` will parse a sign, `UInt.parser()` will not.).
If you want to parse a number without a sign, use a more explicit parser, or test for the sign before using `Int.parser()`. _E.g._:
```swift
let digits = Prefix { $0.isNumber }.compactMap(Int.init)
// ...or...
let digits = Parse {
Not { OneOf { "-"; "+" } }
Int.parser()
}
```
- Updated: `Double.parser()` can now be used on any type that conforms to `BinaryFloatingPoint`, including `Float16`.
- Updated: `Many`'s `updateAccumulatingResult` can now throw.
- Updated: Documentation has been revamped, including a new DocC-based static site with articles that cover common topics.
- Infrastructure: Documentation fixes (thanks @haikusw).
- Improved: Error messages that occur at the same input range are now coalesced into a single error (thanks @mayoff).
- Fixed: `Prefix` now eagerly consumes input.
- Fixed: `Prefix` with a minimum length now throws an error at the correct input location, rather than the input location of that minimum length.
- Infrastructure: README and documentation updates.