ExTorch.ModuleMixin (extorch v0.1.0-pre0)

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

Link to this section Summary

Functions

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

Link to this section Functions

Link to this macro

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

Implementation notes

The function definitions are given via defdelegate internally.