I find it difficult to divide my modules into different concerns without having to change client code like you would do with ActiveSupport::Concern in Ruby.
For example, if I have a main module which others use like:
defmodule MyApp do
def fun_1 do
# implementation or calling another module
end
def fun_2 do
# implementation or calling another module
end
# ...
def fun_n do
# implementation or calling another module
end
end
However if I want to divide this up into separate modules to keep the internal code cleaner like:
defmodule MyApp do
import Functionality1
import Functionality2
import Functionality3
end
Then `MyApp.fun_1` no longer works. In order to move code out into separate modules but still have things work the same, one must do something like the following:
defmodule MyApp do
alias Functionality1, as: F1
alias Functionality2, as: F2
alias Functionality3, as: F3
@inline true
def fun_1(arg1, arg2, arg3) do
F1.fun_1(arg1, arg2, arg3)
end
@inline true
def fun_2(arg1, arg2, arg3) do
F2.fun_2(arg1, arg2, arg3)
end
@inline true
def fun_3(arg1, arg2, arg3) do
F3.fun_3(arg1, arg2, arg3)
end
end
But now the documentation must be here with this module instead of in the other module where the implementation is located.
What I propose instead is simply inlining the calls to the other module and copying the documentation within an `export` macro. Like this:
defmodule MyApp do
export Functionality1
export Functionality2
export Functionality3
end
Then `MyApp.fun_1(1,2,3)` works as expected, `h MyApp.fun_1/3` works as expected, but I can easily divide my code into separate concerns without cluttering everything into a single module file.
Effectively, this is the opposite of the `import` functionality. Instead of making those functions available internally within the module, they are available externally through the current module.
Thoughts?