Just wanted to share our experience taking this for a spin in swift-parsing. This feature is great!
A few fun observations:
- We were able to delete over 21K lines of generated code.
- We were able to improve the arity of concatenating parsers from 6 total per block to 10+, where 10 is the number of non-
Void
parsers, and+
is an unlimited number ofVoid
parsers throughout.Expand for example…
Previously, we were limited to 6 parsers total in a builder block:
let x = Parse { "hello" "world" Int.parser() "hello" "world" Int.parser() }
Because
Void
outputs are automatically discarded, we could nest to get things further along, but it makes things much less readable:let x = Parse { Parse { "hello" "world" Int.parser() "hello" "world" } Parse { Int.parser() "hello" "world" } Parse { Int.parser() "hello" "world" } Parse { Int.parser() "hello" "world" } Parse { Int.parser() "hello" "world" } Parse { Int.parser() "hello" "world" } }
Using
buildPartialBlock
, we can now do this:let x = Parse { "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" Int.parser() "hello" "world" }
- We were able to improve the arity of alternating parsers from 10 to unlimited.
- Compile times also improved significantly (from 20 seconds to <2 seconds in debug mode).