MatchResult

com.phasmidsoftware.matchers.Matchers.MatchResult
See theMatchResult companion trait
object MatchResult

Companion object for the MatchResult type. Provides utility methods for constructing and aggregating MatchResult values.

Attributes

Companion
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Matchers.this.Matchers.this.MatchResult.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply[R](r: => R): Matchers.this.MatchResult[R]

Method to construct a MatchResult based on r.

Method to construct a MatchResult based on r.

Type parameters

R

the type of r and of the resulting MatchResult.

Value parameters

r

a call-by-name value of R.

Attributes

Returns

either a Match[R] or an Error[R].

def apply[T, R](b: Boolean, t: T, r: R): Matchers.this.MatchResult[R]

Construct a MatchResult[R] based on a Boolean, a T, and an R. If b is true, then the result is Match(r); otherwise it is Miss(t).

Construct a MatchResult[R] based on a Boolean, a T, and an R. If b is true, then the result is Match(r); otherwise it is Miss(t).

Type parameters

R

result type.

T

input type.

Value parameters

b

a Boolean.

r

an R.

t

a T.

Attributes

Returns

MatchResult[R].

def apply[T, R](e: Either[T, R]): Matchers.this.MatchResult[R]

Construct a MatchResult[R] based on an Either[T, R].

Construct a MatchResult[R] based on an Either[T, R].

Type parameters

R

the Match type.

T

the Miss type.

Value parameters

e

either a Left[T] (miss) or a Right[R] (match).

Attributes

Returns

a MatchResult[R]

def apply[R](r: R, o: R): Matchers.this.MatchResult[R]

Compares two input values of the same type and returns a MatchResult based on their equality. There is a side-effect of printing a message to the standard error stream indicating the match result. This method is intended primarily for debugging purposes.

Compares two input values of the same type and returns a MatchResult based on their equality. There is a side-effect of printing a message to the standard error stream indicating the match result. This method is intended primarily for debugging purposes.

Type parameters

R

the type of the values being compared to create the match result.

Value parameters

o

The second value to compare.

r

The first value to compare.

Attributes

Returns

A MatchResult containing the first value if the comparison succeeds.

def apply[Q, T, R](f: T => R, p: (Q, R) => Boolean)(q: Q, t: T): Matchers.this.MatchResult[R]

Yield a MatchResult[R] based on an input value t, a function f, and a predicate p.

Yield a MatchResult[R] based on an input value t, a function f, and a predicate p.

Type parameters

Q

the control type.

R

the result type.

T

the input type.

Value parameters

f

the function T => R.

p

the predicate which is applied to (q, r) to determines whether the result is a Match or a Miss, where r is the result of applying f to t.

q

the control value.

t

the input value.

Attributes

Returns

a MatchResult[R].

def create[Q, T, R](p: (Q, R) => Boolean)(q: Q, t: T, r: R): Matchers.this.MatchResult[R]

Create a MatchResult based on an input value t, a result r, and a predicate p.

Create a MatchResult based on an input value t, a result r, and a predicate p.

Type parameters

Q

the control type.

R

the result type.

T

the input type.

Value parameters

p

the predicate that determines whether the result is a Match or a Miss.

r

the result value.

t

the input value (ignored for a Match).

Attributes

Returns

a MatchResult[R].

def sequence[R](rms: Seq[Matchers.this.MatchResult[R]]): Matchers.this.MatchResult[Seq[R]]

Aggregates a sequence of MatchResult objects into a single MatchResult containing a sequence of the matched results. This method processes the provided sequence and:

Aggregates a sequence of MatchResult objects into a single MatchResult containing a sequence of the matched results. This method processes the provided sequence and:

  • Combines successful Match instances by collecting all their matched values.
  • Propagates the first encountered Error instance, if any.
  • Preserves Miss instances if no Error is present. CONSIDER using accumulate

If the result is a Match, then at least one element of rms was a Match. If the result is a Miss, then each of the elements of rms was a Miss.

Type parameters

R

the type of the matched value.

Value parameters

rms

the sequence of MatchResult objects to be processed.

Attributes

Returns

a MatchResult containing a sequence of matched results, the first Error encountered, or a sequence reflecting Miss instances if no Error is present.

def sequenceStrict[R](rms: Seq[Matchers.this.MatchResult[R]]): Matchers.this.MatchResult[Seq[R]]

Strictly aggregates a sequence of MatchResult objects into a single MatchResult containing a sequence of the matched results. If all MatchResults in the provided sequence are successful Match instances, the resulting MatchResult will also be successful, containing a sequence of all matched values. If any MatchResult in the sequence represents a failure, the aggregation stops at the first failure and returns that. CONSIDER using accumulate

Strictly aggregates a sequence of MatchResult objects into a single MatchResult containing a sequence of the matched results. If all MatchResults in the provided sequence are successful Match instances, the resulting MatchResult will also be successful, containing a sequence of all matched values. If any MatchResult in the sequence represents a failure, the aggregation stops at the first failure and returns that. CONSIDER using accumulate

Type parameters

R

the type of the matched value.

Value parameters

rms

the sequence of MatchResult objects to be aggregated.

Attributes

Returns

a MatchResult containing a sequence of matched results or the first failure encountered.