-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Motivation
We want to measure the impact of partial type constructors on GHC (and, if possible, packages from Hackage). The thought is to get data something like this:
| Package | Module | declarations modified (w/ Total) |
declarations modified (w/ WFT or @) |
|---|---|---|---|
| Cabal | Foobar | schifty Schfive | Elevenzies |
| .... | ... | ......... | ........... |
My idea, at least, to motivate this, is that we have separate sections in the paper on challenges in implementation -- i.e, why we need the Total constraint synonym, or why we need the WFT workaround. Tabulating modifications made to packages by these categories of fixes will allow us to state their impact clearly.
Considerations
If we simply want to count the types we see Total, WFT, or @ added to a declaration, we could just grep. However it would be better to not double dip. Take for example this gem from compiler/Hs/Expr.hs:
pprBinds :: (
#if MIN_VERSION_base(4,16,0)
WFT (XOverLit (GhcPass idR)),
WFT (XOverLit (GhcPass (NoGhcTcPass idR))),
WFT (XOverLit (GhcPass idL)),
WFT (XOverLit (GhcPass (NoGhcTcPass idL))),
WFT (Anno (IdGhcP idR)),
WFT (Anno (IdGhcP (NoGhcTcPass idR))),
WFT (Anno (IdGhcP idL)),
WFT (Anno (IdGhcP (NoGhcTcPass idL))),
WFT (SyntaxExprGhc idL),
WFT (SyntaxExprGhc (NoGhcTcPass idL)),
WFT (SyntaxExprGhc idR),
WFT (SyntaxExprGhc (NoGhcTcPass idR)),
#endif
OutputableBndrId idL, OutputableBndrId idR)
=> HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDocThis should increment the declarations x modified w/ WFT just once in:
| Package | Module | declarations modified (w/ Total) |
declarations modified (w/ WFT or @) |
|---|---|---|---|
| Ghc | Ghc.Hs.Expr | ... | x + 1 |
Do note that, I think if we see something like:
foobar :: (Total f, f @ a, WFT G) :: ...that this should increment both the Total field and the WFT / @ field.
Implementation (the less knuckle-headed approach)
I'll want to modify some monad to retain (possibly multiple) Name -> Int maps. Then, when type checking term signatures, instance declarations, or class declarations (these are principally the areas where we must add constraint annotations), I can increment each Name when we see Total, @, or WFT in these signatures' constraints. @ is a wiredin type constructor, so that one should be easy to look for -- I am not sure about Total and WFT. Some care will also need to be placed on doing this before elaboration.
After typechecking, I can dump out this data in the tc trace -- or, make a new dump file. Ideally, I can dump a separate file per module/file into either the _build directory location of that file, or, the module's original location. We can do post-processing thereafter.
Implementation (Leeroy Jenkins)
Just print out a line in the tc trace with all the data you need every time you see the reserved keywords, then aggregate using grep hackery.
Implementation (Edit)
yeah just grep