koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.16k stars 151 forks source link

Identifier hiding/showing and Qualified Modules #531

Open TimWhiting opened 1 month ago

TimWhiting commented 1 month ago

It would be nice to be able to hide or show certain parts of modules or require them to be prefixed by module name (without also requiring them to be prefixed by local qualifiers).

Especially when considering the implicit and overloading resolution.

It also might be useful for this to be a local mechanism and not just global at the import statement.

I'm not sure the best design, or whether to just allow hide or just allow show, or just requiring module names.

The problem with just requiring module names, is that it might cause issues with implicit resolution, though I guess that might be the point of hiding that particular module - but what if you want one definition in the imported module to participate in implicit resolution, but not another.

I think importing as qualified though would be a useful feature in general.

Additionally I think we should at the very least support something more general than at a specific identifier level like:

import qualified something =  s, showing implicits
// and
import something, hiding implicits

Which would allow it to resolve implicits, while still requiring using the qualified identifier elsewhere or hide the module's definitions from participating in implicit resolution.

The default of qualified imports actually might be to resolve implicits.

At a local level, we could add a using expression? Which would then for that section of code reimport the required module but under different scope.

using modulename = mod1 hiding implicits
...