title: Is it possible to dynamically access module by string or symbol?
body: <p>I'm trying to write a set of macros all of which would have to depend on the knowledge about the same module and hence, I'm trying to avoid passing this module explicitly to each function (I'm actually fine with doing so, but as I'm learning the language I'm trying to explore all the possibilities!).</p>
  
  <p>So I'm writing (The goal is to access <code>SomeOtherModule</code>, or invoke <code>SomeOtherModule.foo</code> inside the generated <code>foo</code> function.)</p>
  
  <pre><code>defmodule MacrosUser do
    use MyMacros, SomeOtherModule
  end
  
  defmodule MyMacros do
    defmacro __using__(opts) do
      {:__aliases__, _, module_path} = opts
      quote do
        def foo do
          module_path
          |&gt; Enum.join(".")
          |&gt; apply(:foo, [])
        end
      end
    end
  end
  </code></pre>
  
  <p>But this obviously doesn't work as <code>apply/3</code> expect a module and not a string or symbol representation of the module's name.</p>
  
  <p>Basically, as the title says, I'm looking for some way to make it so that for a given string or symbol it would access the corresponding module or invoke a function of that module.</p>
  
  <p>Also, I know that it's possible to access the current module via <code>__MODULE__</code> in macro, but I'm looking for a way to access any existing module, not only the current one.</p>