Previously, the sort done for pretty printing used If. Because of how type families work, this doesn't short circuit like value-level if, and always evaluates both branches, which made sorting very slow and run out of memory with a larger schema like in (credit @wyao-simspace ). Sorting only happens in the case of an error, so this didn't come up in normal testing.
This changes the sort logic to use a custom type family that does only evaluate one branch of the conditional. This improves the performance so that we can compile the above schema, up until it (as expected) reports a type error. Also tested was a schema with 250 entries, which also worked with -freduction-depth=0 set. I don't have the above added as a test, because it by design throws a type error.
Previously, the sort done for pretty printing used
If
. Because of how type families work, this doesn't short circuit like value-level if, and always evaluates both branches, which made sorting very slow and run out of memory with a larger schema like in (credit @wyao-simspace ). Sorting only happens in the case of an error, so this didn't come up in normal testing.This changes the sort logic to use a custom type family that does only evaluate one branch of the conditional. This improves the performance so that we can compile the above schema, up until it (as expected) reports a type error. Also tested was a schema with 250 entries, which also worked with
-freduction-depth=0
set. I don't have the above added as a test, because it by design throws a type error.