View Source JetExt.Types (jet_ext v0.2.4)

Define types that used in the jet projects.

Summary

Types

Used to declare the key of a Keyword as mandatory.

Functions

Make sum type from a list of modules.

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

Link to this function

make_module_sum_type(modules, type)

View Source
@spec make_module_sum_type([module(), ...], atom()) :: Macro.t()

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)
@spec make_sum_type([atom(), ...]) :: Macro.t()

Make sum type.

iex> JetExt.Types.make_sum_type([:foo, :bar, :baz])
quote do :foo | :bar | :baz end