Add -fcompact-holes.
Needs RevisionPublic

Authored by kosmikus on Sun, Nov 18, 9:22 AM.

Details

Summary

This adds a -fcompact-holes flag that prints typed hole
error messages in a more compact format.

Also adds a user guide entry for the flag and test cases.

kosmikus created this revision.Sun, Nov 18, 9:22 AM
tdammers requested changes to this revision.Mon, Nov 19, 4:57 AM
tdammers added a subscriber: tdammers.

Not sure if these two are actually worth fixing, but thought I'd mention them anyway.

compiler/typecheck/TcErrors.hs
2950

Looks like a mild case of Boolean Blindness to me - iow, having data HolePrinting = PrintHolesNormally | PrintCompactHoles or something like that here would probably increase clarity (and have the compiler remind us when we flip the arguments)

testsuite/tests/typecheck/should_compile/compact_holes_hole_fits.stderr
191

This long list of possible hole fits makes me a bit uneasy, because it means that there is a high chance of unrelated changes (adding things to Prelude, or changing the type of something in Prelude) leading to this test failing - even though the regression it is supposed to detect isn't present.

The most pragmatic solution I can think of would be to use an explicit Prelude import here, with just a small list of things that we absolutely need to have in scope, and designed to minimize the chance of future type changes; then the expected output will be both smaller and less likely to deviate in the case of an unrelated change to Prelude.

This revision now requires changes to proceed.Mon, Nov 19, 4:57 AM

Thanks for the review.

compiler/typecheck/TcErrors.hs
2950

I'm happy to do that, and probably would have if there hadn't been another Bool argument for the filtering already. But you're also right that it's actually making the situation much worse, because there are now two Boolean arguments in direct succession.

Do you think I should introduce a data for the other Bool argument as well then, even if that'd be an unrelated refactoring?

testsuite/tests/typecheck/should_compile/compact_holes_hole_fits.stderr
191

This is an adapted copy of an already existing test case, namely holes.hs, which suffers from exactly the same problem. I am nevertheless happy to change it though.