3 ms·
I think Haskell or OCaml would do a better job on the ADTs for a parse tree. When doing this, I found Rust's enums... anemic... and got very annoyed by the awkw
by cmrdporcupine 3y ago
I think Haskell or OCaml would do a better job on the ADTs for a parse tree. When doing this, I found Rust's enums... anemic... and got very annoyed by the awkwardness of having to Box recursive types. I was reaching for the ability to continue to be able to pattern match on nodes while attaching common attributes (line numbers, etc.) and ended up having to bury everything 1 level deep in a struct which ended up feeling awkward.
That and Rust's iterators are terrible at introducing ownership agony.
In any case, I've ... done it (https://github.com/rdaum/moor/blob/main/crates/compiler/src/parse.rs https://github.com/rdaum/moor/blob/main/crates/compiler/src/...) but can't say I liked it.
I do really like "pest" as a parser generator though. In general, yes, the Rust ecosystem is bigger/richer, and growing.
- di4na 3y agoYou are not wrong on that level, i have been slowly writing a language in Rust anc all these point are deeply felt. And yet... The Rust ecosystem win. Easily. For a simple reason. Salsa. Oh and also clap. Lsp bindings. Ungrammar. Miette. Clap. Parsers. Etc At every level the Rust packages are far better and allow to drastically reduce the cost of building this stuff.
- throwaway858 3y agoHaskell has equivalents to all of those libraries, and much more. And they are probably easier to use and more powerful.
- Philpax 3y agoCan you link some of those libraries? I’ve always found it harder to find well-maintained libraries that solve compiler problems in Haskell as opposed to Rust.
- di4na 3y agoI spent 6 months exploring the Haskell ecosystem for these. The answer is no. They are nowhere as easy. At the very least because their documentation is usually non existent or non comprehensible.