Skip to content

Applicative combinators instead of construct! #333

Answered by pacak
mausch asked this question in Q&A
Discussion options

You must be logged in to vote

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 and construct! 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 (say a: impl Parser<A> and b: impl Parser<B>) you have variables (a: A and b: B) and you simply construct the result: Foo { a, b }. construct!(Foo { a, b }) does the same but with Parsers, giving you impl Parser<Foo> back. A tiny bit of magic allows you to use () to specify that a

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mausch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants