
And then have the compiler automatically include (optional) package name, module name, and line number where `headContext` was called. How about we borrow a bit from rewrite rules, and have a pragma such as:
{-# WITH_CONTEXT head headContext #-}
This seems similar to the SRCLOC_ANNOTATE pragma supported by jhc. I'd love to have this feature. I'd just like to point out it's not just useful for partial functions like 'head', but also for logging and "expected" exceptions like Left. It's also extremely useful for tests, when I get "check failed: 3 /= 4" it's really important to see filename and line number. There are various hacks out there to get this, but they all involve annotating the call sites with some magic, either an 'assert' (and then runtime overhead on every function that uses it) or a TH splice (and then you have to turn TH on in every module). I have literally thousands of lines of tests that would all need an extra boilerplate argument. I implemented a preprocessor that is effectively like SRCLOC_ANNOTATE and it works ok for me, but it's not a good general solution because it's hardcoded to certain symbols and slows down compilation too much. And being specific to my app of course it wouldn't help in your case :) But it won't happen unless one of us few people who care about it just goes and implements it. I don't think it's much of a priority with others.