Counter-intuitively, if you're writing a parser for a programming language, you need it to be a total function. As soon as you build IDE tooling, you need ASTs from invalid or incomplete input.
The parser should return (Ast, List<Error>) rather than Result<Ast, Error>.
Related Posts
I think you could build an interesting IDE with a tiny embedded LLM in addition to the usual tooling.
Features like 'extract method' would be much nicer if an LLM could provide a name. Choosing a good name is virtually impossible from just a typed AST.
Playing with optional type signatures in Python, I realise that the return type is the most important to me.
I'd much rather have a function with only a return type instead of a function with only parameter types. It's often quick to add too.
Really cute approach to reporting type errors: when there's a type error, show an example of a runtime error that the type check has prevented!
Data-Driven Techniques for Type Error Diagnosis https://escholarship.org/uc/item/59s4h4pv