ExTorch.ModuleMixin (extorch v0.2.0)

Copy Markdown

Utilities used to define a module mixin that inherits documentation and specs.

Summary

Functions

This macro enables a module to import the functions from another module and expose them as they were defined on it.

Functions

extends(module)

(macro)

This macro enables a module to import the functions from another module and expose them as they were defined on it.

defmodule BaseModule do
  def call1(arg1, arg2) do
    arg1 + arg2
  end

  def call2() do
    :ok
  end
end

defmodule Mixin do
  import ExTorch.ModuleMixin
  extends(BaseModule)
end

By using the extends/1 macro, the Mixin module will have the definitions of call1/2 and call2/0.

Implementation notes

The function definitions are given via defdelegate internally.