The convention is to create a type called t using the @type attribute.
defmodule MyApp.Foo do
defstruct [:foo, :bar]
@typedoc "My Foo data type."
@type t :: %__MODULE__{foo: String.t(), bar: String.t()}
@spec new_foo(keyword) :: t
def new_foo(opts) do
struct!(__MODULE__, opts)
end
end
You can reference your new type from other modules with MyApp.Foo.t() just as you would String.t().


















