Companion object for the MatchResult type. Provides utility methods for constructing and aggregating MatchResult values.
Attributes
- Companion
- trait
- Graph
-
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Members list
Type members
Inherited and Abstract types
The names of the product elements.
The names of the product elements.
Attributes
- Inherited from:
- Mirror
The name of the type.
The name of the type.
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
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].
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].
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]
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
MatchResultcontaining the first value if the comparison succeeds.
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].
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].
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
Matchinstances by collecting all their matched values. - Propagates the first encountered
Errorinstance, if any. - Preserves
Missinstances if noErroris present. CONSIDER usingaccumulate
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
MatchResultobjects to be processed.
Attributes
- Returns
-
a
MatchResultcontaining a sequence of matched results, the first Error encountered, or a sequence reflecting Miss instances if no Error is present.
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
MatchResultobjects to be aggregated.
Attributes
- Returns
-
a
MatchResultcontaining a sequence of matched results or the first failure encountered.