65d30338

Created Started Cancelled

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Give every rule a directory

A rule was one module, and anything else it needed was somewhere else: its
fact in the shared Facts module, the reading of the parse tree that produces
that fact in the shared Extract. So what a rule cost could not be read off
the rule, and the two places everything else went were the two that grew with
every rule added.

A rule is now a directory. Rule.hs is the check, and beside it goes whatever
only that rule needs: Fact.hs for a fact nothing else reads, Extract.hs for
the reading that produces it. Five of the six rules need neither and are the
one module, in a directory of their own so the shape is the same for all of
them.

HsNoSemigroupOnText is the one with all three, and it is now 178 lines that
were spread over three shared modules: 30 of rule, 44 of fact, 104 of reading.
That last number is the interesting one. It was invisible while it sat in
Hopinion.Extract, and it is what M5 has to stop a later expression rule from
paying again.

What no rule owns moved to Hopinion.Extract.Ghc: a GHC span as a fact's span,
the declaration a span falls inside, and taking an expression apart far enough
to see what it is. A rule's own extraction asks that for the parts it shares
rather than importing Hopinion.Extract, which would have made the two import
each other. It is also where the walking M5 plans to centralise belongs.

ModuleContext still carries a field per module-level fact, so it imports the
fact of any rule that brings one. That is the one edge left pointing from the
middle of the tool at a rule, and it is why the rule directory holds the fact
rather than the fact holding the rule.
GitHub