logoalt Hacker News

ryandv11/08/20243 repliesview on HN

I don't know. Having written a small parser [0] for Forsyth-Edwards chess notation [1] Haskell takes the cake here in terms of simplicity and legibility; it reads almost as clearly as BNF, and there is very little technical ceremony involved, letting you focus on the actual grammar of whatever it is you are trying to parse.

[0] https://github.com/ryandv/chesskell/blob/master/src/Chess/Fa...

[1] https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notati...


Replies

PittleyDunkin11/08/2024

Haskell definitely takes the cake in terms of leveraging parser combinators, but you’re still stuck with Haskell to deal with the result.

show 5 replies
nine_k11/08/2024

But this is not unaided Haskell, it's a parser combinator library, isn't it?

Do you see an obvious reason why a similar approach won't work in Rust? E.g. winnow [1] seems to offer declarative enough style, and there are several more parser combinator libraries in Rust.

[1]: https://docs.rs/winnow/latest/winnow/

show 2 replies
lynx2311/08/2024

I wouldn't consider FEN a great parsing example, simply because it can be implement in a simple function with a single loop.

Just a few days ago, I wrote a FEN "parser" for an experimental quad-bitboard impelementation. It almost wrote itself.

P.S.: I am the author of chessIO on Hackage