I'm learning OCaml at the moment, and I was caught out by the syntax today. This code (pictured) gives a type error saying that Sad is not a boolean. https://gist.github.com/Wilfred/ce4b7177f404a482b8fccc0044d15e4c
This is the classic 'dangling else' syntax problem, but with match statements rather than if statements.
Related Posts
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
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.
I'm experimenting with syntax in examples. I don't really like Rust's `assert(inc(1) == 2)` syntax, I find it a little distracting.
I'm trying `inc(1) //-> 2`. The comment is rendered differently, and there's nothing before the sample code. What do you think?