Re-exporting types

In order to namespace things within a module it makes sense to use nested package names (i.e. com.domain.mymodule.mysubmodule.model.someclass). But it would be lead to a better API if it were possible to flatten this for its public API (i.e. com.domain.mymodule.someclass).

I suppose this is somewhat possible using a typeAlias. But this would mean both the typeAlias and the original class being exposed publicly.

In rust it is possible to re-export an internal type publicly using the syntax:

use pub some:nested:type:foo as foo

I have recently started using Kotlin, so apologies if this feature is already possible. At the moment I cannot see there is a way to create a nice, flat API for public consumers, without forgoing the ability to nicely namespace things internally?

I’m not sure I understand what value I would gain from flattening an API’s imports. Since imports are rarely physically typed, there are hardly any characters saved.

I imagine you could move the classes into more meaningful package names and add value that way. But that’s adding information and you want to remove information. Can you elaborate why this is done in Rust–why do you describe a flattened API as “better”?

Aside from not seeing the value added, I can image it causing confusion since any class may be located somewhere not expected. IMHO, more specific package names make a clearer API.