Skip to content

First class support for the import module pattern #14061

@rgrinberg

Description

@rgrinberg

Problem

The import module pattern is a common pattern used to reduce the number of qualified names in a library. It consists of writing an import.ml consisting of aliases like:

module Foo = Lib.Foo
...

And then doing open Import in every other module.

The problem with this pattern is that it completely defeats the optimization in #14021.

Solution

We need to lift this import module pattern to the level of dune files so that dune understands all the aliases in scope. Here's a simple way to do so:

(library
 (imported_modules (lib foo bar ..))
 ..)

Where the first token is the name of the library, and the rest are module names.

Now dune should be able to know which modules are in scope when refining library dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions