mamot.fr is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mamot.fr est un serveur Mastodon francophone, géré par La Quadrature du Net.

Server stats:

3.5K
active users

Marc

Quick question about : how do I get rid those ugly nested tuples in the final map? No way to discard them for real and receive a map(| (a, b)| ... ) ?

@corpsmoderne
If I recall correctly from my own experiments those are inherent to the way combinators work.

@faassen well my experience with parser combinators in Haskell tends to say otherwise, but there's maybe something specific going on with Rust or Chumsky's design choices...

@corpsmoderne
I think it's how types of functions are combined but I forget the details. I just remember writing my own combinator framework and this fell out. Hopefully @jsbarretto can explain better

@corpsmoderne @faassen This is an inherent thing. `then` takes parsers of `A` and `B` and produces a parser of `(A, B)`.

There is a `group` combinator that accepts a tuple of parsers and produces a tuple of outputs, which might be what you're looking for?

@corpsmoderne @faassen Oh, I didn't read your code properly. The first `.ignored().then(..)` can be replaced with `.ignore_then(..)`

@jsbarretto @faassen I was about to reply "why then_ignore() exists and not ignore_then() ?", I just have missed it 😅 thanks for the heads-up!

@corpsmoderne @faassen No worries! Out of interest, are you using 0.9 or 1.0?

@jsbarretto @faassen 0.9.3 (was cargo added a couple of days ago, it installed this version.)

@corpsmoderne @faassen Ah, fair enough. If you decide to switch to 1.0 at any point (I'd recommend it, it's where the nice new features and the decent performance lives!) there's a guide. The 'Meet The Parsers' page in particular you might find useful: docs.rs/chumsky/1.0.0-alpha.7/

docs.rschumsky::guide - RustWelcome to chumsky

@jsbarretto

@corpsmoderne

Oh sorry I missed the empty tuple and didn't think about ignoring bits

@corpsmoderne you can use an intermediary map() to just flatten it into a tuple you like better, which is quite convenient to do in between some combinators to avoid nested madness.