Mentions légales du service

Skip to content

(RFC) Removing "leaf" functions from module signatures

SCHERER Gabriel requested to merge gscherer/inferno:unleafing into master

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 with type '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 in make 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 just map (which is not an important distinction I think given that iter is definable from map, 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 where S 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.

Edited by SCHERER Gabriel

Merge request reports