I'm designing a programming language and trying to decide the type of `let x = 1;`. Should it be Unit or Int?
Advantage of Int: really convenient when evaluating snippets in a REPL.
Advantage of Unit: It's much less confusing when type inference runs on an incomplete function.
miniblog.
Related Posts
I've added syntax highlighting to the prompt of my programming language!
It's not strictly necessary, but it's nice to have. It caught a bug with lexing incomplete string literals too.
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>.
It's surprisingly fiddly to parse unfinished multiline expressions in a REPL.
In Garden, my toy language, the parser distinguishes 'incomplete' from other others, so I can keep appending text and re-parsing until something useful comes out.
