DarkMatter.Guards (DarkMatter v1.1.4) View Source
Utils for working with guard clauses.
Link to this section Summary
Functions
Delegates to DarkMatter.Guards.is_arity/1
.
Delegates to DarkMatter.Guards.is_ecto_struct/1
.
Define a guard clause for working with arity/0
.
Define a guard clause for working with module/0
.
Define a guard clause for working with neg_integer/0
.
Define a guard clause for working with non_neg_integer/0
.
Define a guard clause for working with numerics.
Define a guard clause for working with pos_integer/0
.
Define a guard clause for working with strict numerics.
Delegates to DarkMatter.Guards.is_module/1
.
Delegates to DarkMatter.Guards.is_neg_integer/1
.
Delegates to DarkMatter.Guards.is_numeric/1
.
Delegates to DarkMatter.Guards.is_pos_integer/1
.
Delegates to DarkMatter.Guards.is_strict_numeric/1
.
Link to this section Functions
Specs
Delegates to DarkMatter.Guards.is_arity/1
.
Specs
Delegates to DarkMatter.Guards.is_ecto_struct/1
.
Specs
Delegates to DarkMatter.Guards.is_ecto_struct/2
.
Specs
Define a guard clause for working with arity/0
.
Examples
iex> is_arity(3)
true
iex> is_arity(257)
false
Specs
Define a guard clause for working with Ecto
based struct/0
.
Examples
...>
iex> is_ecto_struct(%{__struct__: MyStruct, __meta__: %Ecto.Schema.Metadata{}})
true
iex> is_ecto_struct(%{__struct__: MyStruct, __meta__: nil})
false
iex> is_ecto_struct(%{})
false
iex> is_ecto_struct(%{__struct__: MyStruct, __meta__: %Ecto.Schema.Metadata{}}, MyStruct)
true
iex> is_ecto_struct(%{__struct__: MyStruct, __meta__: nil}, MyStruct)
false
iex> is_ecto_struct(%{})
false
Specs
Specs
Define a guard clause for working with module/0
.
Examples
iex> is_module(Kernel)
true
iex> is_arity(nil)
false
iex> is_arity(false)
false
Specs
Define a guard clause for working with neg_integer/0
.
Examples
iex> is_neg_integer(-5)
true
iex> is_neg_integer(0)
false
iex> is_neg_integer(99)
false
Specs
Define a guard clause for working with non_neg_integer/0
.
Examples
iex> is_non_neg_integer(3)
true
iex> is_non_neg_integer(0)
true
iex> is_non_neg_integer(-100)
false
Specs
Define a guard clause for working with numerics.
Examples
iex> is_numeric(0)
true
iex> is_numeric(1.1)
true
iex> is_numeric(%Decimal{sign: 1, coef: 1, exp: 1})
true
iex> is_numeric("2.0")
true
iex> is_numeric(%{sign: 1, coef: 1, exp: 1})
true
# Can't handle this currently with macros.
iex> is_numeric("2.0.0")
true
Specs
Define a guard clause for working with pos_integer/0
.
Examples
iex> is_pos_integer(1)
true
iex> is_pos_integer(0)
false
iex> is_pos_integer(-1)
false
Specs
Define a guard clause for working with strict numerics.
Examples
iex> is_strict_numeric(0)
true
iex> is_strict_numeric(1.1)
true
iex> is_strict_numeric(%Decimal{})
true
iex> is_strict_numeric("2.0")
false
Specs
Delegates to DarkMatter.Guards.is_module/1
.
Specs
Delegates to DarkMatter.Guards.is_neg_integer/1
.
Specs
Delegates to DarkMatter.Guards.is_non_neg_integer/1
.
Specs
Delegates to DarkMatter.Guards.is_numeric/1
.
Specs
Delegates to DarkMatter.Guards.is_pos_integer/1
.
Specs
Delegates to DarkMatter.Guards.is_strict_numeric/1
.