Skip to content

[refactor] split constructor/fields types from Types to Data_types#13466

Merged
gasche merged 3 commits intoocaml:trunkfrom
gasche:data_types
Sep 25, 2024
Merged

[refactor] split constructor/fields types from Types to Data_types#13466
gasche merged 3 commits intoocaml:trunkfrom
gasche:data_types

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Sep 22, 2024

One must be careful about changing typing/Types, because (some of) the types it defined are used in .cmi files, so any change to those requires a delicate bootstrap and magic number bump.

This refactoring splits off a part of Types that is not used in .cmi files -- information about record fields and variant constructors. They move to a new typing/Data_types compilation unit, which can evolve more freely.

@gasche gasche changed the title [refactor] split constructor/fields types from Types do Data_types [refactor] split constructor/fields types from Types to Data_types Sep 23, 2024
@gasche gasche force-pushed the data_types branch 2 times, most recently from 6d83610 to 521f9a0 Compare September 23, 2024 20:00
@Octachron
Copy link
Copy Markdown
Member

Should the new module name be Datatypes to match Datarepr? (or Datadesc? Labeldesc?)

Overall, I agree that detaching this module from Types make sense :

  • the field and constructor descriptions are not types
  • they are not used elsewhere in the Types modules
  • they don't need to be privy to Types internal.

I would propose to move the two functions of Btypes label_is_poly and cstr_type_path to the new module to remove the Btype->Datatypes dependency.

Similarly, I would rather avoid opening the full module in the mli for Ctypes andTypecore (and possibly Datarepr) because the new module types are only used once or twice in the interface.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Sep 24, 2024

I applied your recommendations and rebased.

Changes:

  • Btype.cstr_type_path is now Data_types.cstr_res_type_path
  • I removed Btype.label_is_poly (I was not too exited at adding a dependency from Data_types (mostly a types-only module) to Btype (a types-and-logic module))
  • I removed a two of the global open you mentioned (remark: reformating .mli lines to avoid 80 columns is not fun)

I prefer Data_types to Datatypes, because I can see a use for other Foo_types module, for example my in-progress PR has a Head_shape_types module, and Headshapetypes would be ugly. We could change Datadescr into something else, in time (never).

Copy link
Copy Markdown
Member

@Octachron Octachron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks fine to me.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Sep 25, 2024

Thanks! I will fix the typos, massage the history (removing the opens could go in the first commit), merge, and rebase #13467.

One must be careful about changing typing/Types, because (some of) the
types it defines are used in .cmi files, so any change to those
requires a delicate bootstrap and magic number bump.

This refactoring splits off a part of Types that is *not* used in .cmi
files -- information about record fields and variant
constructors. They move to a new typing/Data_types compilation unit,
which can evolve more freely.
Suggested-by: Florian Angeletti <florian.angeletti@inria.fr>
Suggested-by: Florian Angeletti <florian.angeletti@inria.fr>
@gasche gasche merged commit 312f5bc into ocaml:trunk Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants