View Source JetExt.Types (jet_ext v0.2.2)
Define types that used in the jet projects.
Summary
Types
@type as_required(t) :: t
Used to declare the key of a Keyword
as mandatory.
NOTE: It can only be used on the type of the value.
@type options() :: [
required_key: as_required(boolean()),
optional_key: boolean()
]
@type maybe(t) :: t | nil
Functions
Make sum type from a list of modules.
defmodule Foo do
@type t() :: :foo
end
defmodule Bar do
@type t() :: :bar
end
defmodule Baz do
@type t() :: :baz
end
iex> JetExt.Types.make_module_sum_type([Foo, Bar, Baz], :t)
Make sum type.
iex> JetExt.Types.make_sum_type([:foo, :bar, :baz])
quote do :foo | :bar | :baz end