-
Hi and thanks for this library! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Rust doesn't play nicely with currying unfortunately: no higher order types, no curried type applications, lots of things are not |
Beta Was this translation helpful? Give feedback.
construct!
macro works in two different modes: alternative and applicative combinations. For applicative you put parsers for all the variants into a set of square brackets andconstruct!
combines them giving preference to one that consumes earlier item from the command line or one that succeds first in a list if they consume the same item. For applicative the easiest way to think about it is that instead of parsers (saya: impl Parser<A>
andb: impl Parser<B>
) you have variables (a: A
andb: B
) and you simply construct the result:Foo { a, b }
.construct!(Foo { a, b })
does the same but with Parsers, giving youimpl Parser<Foo>
back. A tiny bit of magic allows you to use()
to specify thata