View Source Machete.Matchable protocol (Machete v0.2.2)
Defines a protocol to determine how a given term may match against a type. The
Machete.Matchable
protocol is central to the Machete library, and conformance to it is
necessary for any type to be used on the right hand side of a ~>
match
Link to this section Summary
Functions
Examines the value of the passed term and returns the way(s) in which it does not conform to the
base type instance's requirements, expressed as a list of Machete.Mismatch
structs. If there
are no such mismatches (that is, if the passed term 'matches' against the base type instance),
implementations of this protocol may return an empty list or nil
; they are semantically
equivalent. Implementors of this protocol may be interested in the Machete.Mismatch.mismatch/2
function to easily create mismatches
Link to this section Types
@type t() :: term()
Link to this section Functions
@spec mismatches(t(), term()) :: [Machete.Mismatch.t()] | nil
Examines the value of the passed term and returns the way(s) in which it does not conform to the
base type instance's requirements, expressed as a list of Machete.Mismatch
structs. If there
are no such mismatches (that is, if the passed term 'matches' against the base type instance),
implementations of this protocol may return an empty list or nil
; they are semantically
equivalent. Implementors of this protocol may be interested in the Machete.Mismatch.mismatch/2
function to easily create mismatches