Skip to content

refactor(module_trie): encode module paths as nonempty lists#13144

Merged
anmonteiro merged 1 commit intoocaml:mainfrom
anmonteiro:anmonteiro/module-path-nonempty-list
Dec 31, 2025
Merged

refactor(module_trie): encode module paths as nonempty lists#13144
anmonteiro merged 1 commit intoocaml:mainfrom
anmonteiro:anmonteiro/module-path-nonempty-list

Conversation

@anmonteiro
Copy link
Copy Markdown
Collaborator

  • encodes in the type system that module paths may never be empty (at least they include the module name itslelf).

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
let compare = Nonempty_list.compare ~compare

let to_string Nonempty_list.(t :: ts) =
List.map ~f:to_string (t :: ts) |> String.concat ~sep:"."
Copy link
Copy Markdown
Collaborator

@Alizter Alizter Dec 31, 2025

Choose a reason for hiding this comment

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

Worth introducing Non_empty.to_list_map ~f? This pattern appears here and encode and the two kinds of :: makes it mysterious to read. This is perhaps more readable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also in modules.ml 223

Copy link
Copy Markdown
Collaborator Author

@anmonteiro anmonteiro Dec 31, 2025

Choose a reason for hiding this comment

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

absolutely, i found other places would benefit from this and will introduce in a follow-up PR.

@anmonteiro anmonteiro merged commit 407ac9e into ocaml:main Dec 31, 2025
30 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/module-path-nonempty-list branch December 31, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants