Octachron / codept

Contextual Ocaml DEPendencies Tool: alternative ocaml dependency analyzer
Other
59 stars 10 forks source link

New `modname` module #23

Closed dinosaure closed 1 year ago

dinosaure commented 1 year ago

This PR wants to solve the issue #14 and provide a new module: Modname which is basically a module to implement module names. As explained into the issue, the type is no longer a simple string but an abstract type to keep and enforce assertions about module names.

Currently, only one test remains wrong from this deep change. Implications from this PR on tests are reference by the prefix [test]. We denote 2 big changes: 1) the type Modname.t becomes abstract, we need to use Modname.to_string sometimes but the propagation of this type is not full. To keep the PR clear, I have only dwelt on the most important details and there are places where we could go further in the spread. 2) The Namespaced.t type has 2 views that are useful in many contexts, one view as a module path and one view as a file path. I decided to decouple these views (with a new "file" field) to differentiate between when you want a module path and a file path.

Finally, I haven't updated bundle_refs (see this issue: #21).

This is a draft but it is already a good step to clarify the information handled by codept throughout the resolution process. After this RP, it will be a matter of: 1) further propagate the Modname.t type 2) Abstract Namespace.t and Path.t

dinosaure commented 1 year ago

I did the introduction of the new module Unitname to keep the bijection about the modulize function and use it into the Namespaced module instead of:

Tests did not change (but one test still is commented), just the dependencies graph was updated with the insertion of the new module. Again, I did not propagate the Unitname.t everywhere - I'm waiting to merge this PR first and do this job then. From my perspective and regardless the commented test, it's ready to merge.

This PR integrates #26 too and it will probably be nice to merge #25 before this one. Especially when I updated the implementation of Namespaced.module_path_of_filename and Namespaced.filepath_of_filename.

Octachron commented 1 year ago

I have pushed few fixes, and one change in behavior in Modulize to avoid rewriting names.