Machete.Operators (Machete v0.3.11)
View SourceDefines implementations for the ~>
and ~>>
operators
Summary
Functions
Matches data on the left hand side against matcher(s) on the right hand side. Matching is
determined by calling the Machete.Matchable.mismatches/2
protocol function using the right
hand side's implementation
Returns the list of mismatches between the left and right hand side arguments, determined by
calling the Machete.Matchable.mismatches/2
protocol function using the right hand side's
implementation
Functions
Matches data on the left hand side against matcher(s) on the right hand side. Matching is
determined by calling the Machete.Matchable.mismatches/2
protocol function using the right
hand side's implementation
Examples:
iex> 1 ~> 1
true
iex> 1 ~> integer()
true
iex> "1" ~> integer()
false
iex> %{a: 1, b: "abc"} ~> %{a: 1, b: string()}
true
Returns a boolean result indicating whether the left hand side matched against the right hand side
@spec term() ~>> term() :: [Machete.Mismatch.t()]
Returns the list of mismatches between the left and right hand side arguments, determined by
calling the Machete.Matchable.mismatches/2
protocol function using the right hand side's
implementation
Examples:
iex> 1 ~>> 1
[]
iex> 1 ~>> integer()
[]
iex> "1" ~>> integer()
[%Machete.Mismatch{message: "\"1\" is not an integer", path: []}]
iex> %{a: 1} ~>> %{a: 2}
[%Machete.Mismatch{message: "1 is not equal to 2", path: [:a]}]
Returns a (possibly empty) list of Machete.Mismatch
structs