Notes: 26th October 2026

Mon 26 October 2026

Filed under Posts

Tags weeknotes

Continuing on the surface language constructs. Still finding some surprising bits of complexity. Idris 2's implementation was very much "move fast and break things" which sort of made since because I needed the thing running, but that means, well, you can tell when looking at the implementation. So this time it's more "move slowly and understand what you're doing".

Here's a little detail that Idris 2 gets wrong, and I don't know if anybody has actually noticed, but could be the source of some confusion if you write something just the wrong way - I've just been implementing the elaborator for variables, something you'd think would be simple, because you check if it's defined locally, then check if it's defined globally, then if it's neither, report an error. But "locally" could mean one of two things: is it in the environment (pattern variables or lambda, let, or pi bound things) or is it a locally defined function (e.g. in a where clause, or a local pattern matching definition). So Idris first looks for local definitions, then in the local environment, then globally. While this'll get the right answer most of them time (because hopefully you're not using the same name for a local function definition and a local variable) you could contrive something that makes it not do the right thing (because if you want to write something odd, or indeed have a machine generate something odd, the compiler should support you!)

Anyway. The fix is simple: keep track of the order names are defined so that when you encounter a name, you know where to look. It'd be really annoying to do this fix in Idris 2 (for reasons I won't go into here) but fortunately this time, it's no big deal.


Comments


Edwin Brady © Edwin Brady Powered by Pelican and Twitter Bootstrap. Icons by Font Awesome and Font Awesome More