Alias from module root

I have the following modules:

Foo.Bar
Bar.Module

And I’d like to do this within a module:

alias Foo.Bar
alias Bar.Module

However I get (module Foo.Bar.Module is not available)

Is there a way to make that work?

Something like we’d do in ruby ::Bar.Module to access it from the root.

Thanks

Maybe try to reverse order

alias Bar.Module
alias Foo.Bar

The problem with alias Foo.Bar is You are defining Bar as being Foo.Bar

That might not be a good idea to have 2 modules with the same name… (Foo.Bar and Bar)

3 Likes

Something like we’d do in ruby ::Bar.Module to access it from the root.

Elixir.Bar.Module is an equivalent. But yes, better to avoid conflicting names if possible.

4 Likes

Sounds good, thank you both for the advice!

1 Like

It’s hacky, but I suspect if you reversed the order of your alias declarations, it might work

1 Like