(RFC) Removing "leaf" functions from module signatures
This MR is up for comments, it's trying to remove "leaf" functions from the signatures of Signatures.ml, and generally simplify these signatures. I think it is best looked at commit-per-commit, but any feedback by any means is welcome.
I managed to get rid of all leaf
-related functions through the API, by:
- Exposing the fact that
Structure.Option
returns a structure withtype 'a structure = 'a S.structure option
. - Removing a small optimization in the decoder that would directly decode leaves as variables, without running them through the memoization machinery or anything like that.
make bench
suggests that this has a noticeable-but-very-small performance impact (a 3% increase on allocated words inmake bench
).
Additional simplifications to the interface:
- I collapsed all traversal functions (
map
,iter
,fold
) into the same group, whereas the current code has one signature with justmap
(which is not an important distinction I think given thatiter
is definable frommap
, etc.) - I imposed a
pprint
debug printer for all signatures, getting rid of a special case in one module
Initially my aim was to reveal that generalization "structures" are a pair/product of two different thing:
- a structure of the variable, of type
'a S.structure option
whereS
is the user-provided structure module - information on the binder (the context of use of the variable) with the status, rank, etc.
(so type 'a structure = binder * 'a S.structure option
, instead of going through an abstract structure with project
to decompose it.)
I haven't gotten to the point of trying this, as the existing simplifications already provide good value I think.