The Matchers trait defines behavior including the ability to create and manage many different types of Matcher. A Matcher is a combinator used for pattern matching and transformation based on some rules or functions.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Members list
Type members
Classlikes
Error when matching.
Error when matching.
Type parameters
- R
-
the result-type of this.
Value parameters
- e
-
the exception that was thrown.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Class to add logging to a Matcher.
Class to add logging to a Matcher.
Type parameters
- R
-
the underlying type of the result of the matcher.
- T
-
the underlying type of the input to the matcher.
Value parameters
- f
-
a function T => MatchResult[R].
- logger
-
interpreted as follows: If logger is LogOff, the Matcher instance will simply invoke function f. If logger is LogInfo, then in addition to evaluating function f, a successful match will be logged. If logger is LogDebug, then in addition to evaluating function f, the attempted match and its result will be logged.
- matcherName
-
the name to be used for this matcher.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Successful match.
Successful match.
Type parameters
- R
-
the type of the result.
Value parameters
- r
-
the result.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Companion object for the Match class providing factory methods.
Companion object for the Match class providing factory methods.
This object allows the creation of MatchResult instances by comparing two values of type R. If the two values are equal, a Match is constructed, and a message indicating the match result is printed to the standard error stream.
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Companion object for the MatchResult type. Provides utility methods for constructing and aggregating MatchResult values.
Companion object for the MatchResult type. Provides utility methods for constructing and aggregating MatchResult values.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Trait to define the behavior of the result of a Match.
Trait to define the behavior of the result of a Match.
Type parameters
- R
-
the type of the result.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Implicit class MatchResultOps, which allows us to use the method tee on a MatchResult[R].
Implicit class MatchResultOps, which allows us to use the method tee on a MatchResult[R].
Type parameters
- R
-
the result type of m.
Value parameters
- rr
-
a MatchResult[R].
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Trait that defines the behavior of a Matcher as a function of type T => MatchResult[R] together with other filter-monadic methods, etc...
Trait that defines the behavior of a Matcher as a function of type T => MatchResult[R] together with other filter-monadic methods, etc...
Type parameters
- R
-
the result type.
- T
-
the input type.
Attributes
- Supertypes
- Known subtypes
-
- Self type
Implicit class MatcherOps, which allows us to use the method :| on a Matcher[T,R].
Implicit class MatcherOps, which allows us to use the method :| on a Matcher[T,R].
Type parameters
- R
-
the result type of p.
- T
-
the input type of p.
Value parameters
- p
-
a Matcher[T,R].
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Unsuccessful match (Miss).
Unsuccessful match (Miss).
Type parameters
- R
-
the result-type of this.
- T
-
the underlying type of t.
Value parameters
- t
-
the value that was not matched.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Implicit class ParserOps, which allows us to use the method m on a String.
Implicit class ParserOps, which allows us to use the method m on a String.
Value parameters
- s
-
a String.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Unsuccessful match of type dependent on X.
Unsuccessful match of type dependent on X.
TODO eliminate X (or R?) from the type signature.
Type parameters
- R
-
the result-type of this.
- X
-
the type of x.
Value parameters
- x
-
either a String or a Throwable.
Attributes
- Companion
- object
- Supertypes
- Known subtypes
Extractor object for matching unsuccessful MatchResult values.
Extractor object for matching unsuccessful MatchResult values.
The Unsuccessful object serves as a pattern to extract information from instances of MatchResult that represent an unsuccessful match. It matches error cases and provides access to the underlying details (either an exception or a message) wrapped in a Left or Right.
Attributes
- Companion
- class
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Types
Represents a type alias AutoMatcher[T] which defines a Matcher[T, T] that matches an input value of type T to a MatchResult of the same type T.
Represents a type alias AutoMatcher[T] which defines a Matcher[T, T] that matches an input value of type T to a MatchResult of the same type T.
This type alias can be used to simplify and make the code more readable where such a transformation operation is utilized.
T is the type of both the input and MatchResult values.
Attributes
Value members
Concrete methods
Matcher that tries m on the given (~) input. If m is unsuccessful, it then tries m on the swapped (inverted) ~.
Matcher that tries m on the given (~) input. If m is unsuccessful, it then tries m on the swapped (inverted) ~.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- commutes
-
if true (the default), the order of the incoming ~ elements is immaterial, thus we can try flipping their order. If false then we do not try.
- m
-
a Matcher[T ~ T, R].
Attributes
- Returns
-
a Matcher[T ~ T, R].
Matcher that tries m on the given (~~) input. If m is unsuccessful, it then tries m on the rotated ~~. If that's unsuccessful, it then tries m on the inverted ~~.
Matcher that tries m on the given (~~) input. If m is unsuccessful, it then tries m on the rotated ~~. If that's unsuccessful, it then tries m on the inverted ~~.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- commutes
-
if true (the default), the order of the incoming ~ elements is immaterial, thus we can try rotating their order. If false then we do not try.
- m
-
a Matcher[T ~ T ~ T, R].
Attributes
- Returns
-
a Matcher[T ~ T ~ T, R].
Method to create a named Matcher, based on the given function f of form T => MatchResult[R]. Unusually, this method's identifier has a capital first letter. This is done to mimic the Parser method in the parser-combinators. It has the advantage of looking somewhat like a constructor of a Matcher.
Method to create a named Matcher, based on the given function f of form T => MatchResult[R]. Unusually, this method's identifier has a capital first letter. This is done to mimic the Parser method in the parser-combinators. It has the advantage of looking somewhat like a constructor of a Matcher.
NOTE: if you are looking for a method which takes a function f of form T => R, then you need to use the lift method.
TODO: rename Matcher as UnnamedMatcher and this as Matcher.
If f is a partial function, it may result in a MatchError. In such a case, this is simply treated as a Miss. However, if f throws some other non-fatal exception, then that will result in an Error.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- f
-
a
T => MatchResult[R]. - name
-
the name to be used when debugging this
Matcher
Attributes
- Returns
-
a
Matcher[T, R]based onf.
Method to create a Matcher, based on the given function f of form T => MatchResult[R]. Unusually, this method's identifier has a capital first letter. This is done to mimic the Parser method in the parser-combinators. It has the advantage of looking somewhat like a constructor of a Matcher.
Method to create a Matcher, based on the given function f of form T => MatchResult[R]. Unusually, this method's identifier has a capital first letter. This is done to mimic the Parser method in the parser-combinators. It has the advantage of looking somewhat like a constructor of a Matcher.
NOTE: if you are looking for a method which takes a function f of form T => R, then you need to use the lift method.
If f is a partial function, it may result in a MatchError. In such a case, this is simply treated as a Miss. However, if f throws some other non-fatal exception, then that will result in an Error.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- f
-
a
T => MatchResult[R].
Attributes
- Returns
-
a
Matcher[T, R]based onf.
The alt method returns a Matcher that behaves as follows: It first tries to match the input t according to the given matcher m, in which case the match is returned. If m returns a miss, then a successful match with the value of t will be returned. Therefore, this matcher always succeeds, unless there's an error.
The alt method returns a Matcher that behaves as follows: It first tries to match the input t according to the given matcher m, in which case the match is returned. If m returns a miss, then a successful match with the value of t will be returned. Therefore, this matcher always succeeds, unless there's an error.
Type parameters
- T
-
both the type of the input and the underlying type of the output.
Value parameters
- m
-
an
AutoMatcher[T]
Attributes
- Returns
-
an
AutoMatcher[T]
Defines a Matcher which always succeeds and whose input type and result type are the same.
Defines a Matcher which always succeeds and whose input type and result type are the same.
Type parameters
- R
-
both the input type and the result type.
Attributes
- Returns
-
an
AutoMatcher[R]which always succeeds.
Combines two AutoMatcher instances, attempting to apply the first matcher, and if it results in a match, passing the result to the second matcher. If the first matcher fails, the second matcher is applied directly to the input.
Combines two AutoMatcher instances, attempting to apply the first matcher, and if it results in a match, passing the result to the second matcher. If the first matcher fails, the second matcher is applied directly to the input.
The logic is essentially m1 & m2 | m1 | m2 but that results in over-evaluation.
Value parameters
- m1
-
The first
AutoMatcherto be applied to the input. - m2
-
The second
AutoMatcherto be applied if the first succeeds or fails.
Attributes
- Returns
-
A new
AutoMatcherthat represents the combination of the two input matchers.
Defines a Matcher which always errs and creates an Error with the given exception.
Defines a Matcher which always errs and creates an Error with the given exception.
Type parameters
- R
-
the result type.
Value parameters
- e
-
a
Throwable.
Attributes
- Returns
-
a
Matcher[Any, R]
Defines a Matcher which always fails and creates a Miss with the value tried.
Defines a Matcher which always fails and creates a Miss with the value tried.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- msg
-
the message to describe this failure.
Attributes
- Returns
-
a
Matcher[T, R]
Defines a Matcher which succeeds only if the predicate p evaluates to true. The result will be named "filter."
Defines a Matcher which succeeds only if the predicate p evaluates to true. The result will be named "filter."
Type parameters
- R
-
both the input type and the result type.
Value parameters
- p
-
a predicate on type
R.
Attributes
- Returns
-
an
AutoMatcher[R]which succeeds only ifp(r)istrue.
Method to create a Matcher of a Tilde, which succeeds if the first member matches the given Matcher.
Method to create a Matcher of a Tilde, which succeeds if the first member matches the given Matcher.
Type parameters
- R0
-
type of result's first member.
- T0
-
first of the member types.
- T1
-
second of the member types.
Attributes
- Returns
-
a Matcher[T0 ~ T1, R0 ~ T1].
Method to create a Matcher of ~, which succeeds if the first member matches the given Matcher.
Method to create a Matcher of ~, which succeeds if the first member matches the given Matcher.
Type parameters
- R1
-
type of result's second member.
- T0
-
first of the input member types.
- T1
-
second of the input member types.
Attributes
- Returns
-
a Matcher[T0 ~ T1, T0 ~ R1].
Method to create a Matcher of ~~, which succeeds if the first member matches the given Matcher.
Method to create a Matcher of ~~, which succeeds if the first member matches the given Matcher.
Type parameters
- R0
-
type of result's first member.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, R0 ~ T1 ~ T2].
Method to create a Matcher of ~~, which succeeds if the second member matches the given Matcher.
Method to create a Matcher of ~~, which succeeds if the second member matches the given Matcher.
Type parameters
- R1
-
type of result's second member.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, T0 ~ R1 ~ T2].
Method to create a Matcher of ~~, which succeeds if the third member matches the given Matcher.
Method to create a Matcher of ~~, which succeeds if the third member matches the given Matcher.
Type parameters
- R2
-
type of result's third member.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, T0 ~ T1 ~ R2].
Defines a Matcher which succeeds only if the predicate p evaluates to false. The result will be named "filterNot."
Defines a Matcher which succeeds only if the predicate p evaluates to false. The result will be named "filterNot."
Type parameters
- R
-
both the input type and the result type.
Value parameters
- p
-
a predicate on type
R.
Attributes
- Returns
-
an
AutoMatcher[R]which succeeds only ifp(r)isfalse.
Method to create a Matcher which operates on a similar, but inverted, ~ as m.
Method to create a Matcher which operates on a similar, but inverted, ~ as m.
Type parameters
- R
-
the result type.
- T0
-
one of the input types.
- T1
-
the other input type.
Value parameters
- m
-
a Matcher[T0 ~ T1, R].
Attributes
- Returns
-
a Matcher[T1 ~ T0, R].
Method to match a T, resulting in an R, where the match is indirectly determined by the given lens function.
Method to match a T, resulting in an R, where the match is indirectly determined by the given lens function.
Type parameters
- U
-
the type of the property that is matched by m.
Value parameters
- lens
-
a function T => U.
- m
-
a Matcher[U, R].
Attributes
- Returns
-
a Matcher[T, R]
Method to invert the order of elements in a ~~.
Method to invert the order of elements in a ~~.
Type parameters
- T0
-
the first element type.
- T1
-
the second element type.
- T2
-
the third element type.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, T2 ~ T1 ~ T0].
Convenience predicate for use with create and similar methods that require a (Q, R) => Boolean argument.
Convenience predicate for use with create and similar methods that require a (Q, R) => Boolean argument.
Example:
MatchResult.create(isEqual)(expectedValue, inputValue, resultValue)
This is equivalent to _ == _ but can be passed by name where a named function reference is cleaner than a lambda.
Type parameters
- R
-
the common type.
Value parameters
- q
-
a control value.
- r
-
a result value.
Attributes
- Returns
-
true if q == r.
Evaluates a predicate function on a value of type R and returns a result indicating whether the predicate was satisfied.
Evaluates a predicate function on a value of type R and returns a result indicating whether the predicate was satisfied.
Value parameters
- f
-
a predicate function that takes an argument of type
Rand returns a boolean. - r
-
the value of type
Rto be evaluated by the predicate function.
Attributes
- Returns
-
a
MatchResult[R]which is aMatchif the predicate evaluates to true, or aMisscontaining a message and the evaluated value if the predicate evaluates to false.
Method to define a Matcher based on the function f. The result will identify as "lift". Use namedLift if you want to be more specific.
Method to define a Matcher based on the function f. The result will identify as "lift". Use namedLift if you want to be more specific.
Type parameters
- R
-
the result type to both
fand the resultingMatcher. - T
-
the input type to both
fand the resultingMatcher.
Value parameters
- f
-
a function of type
T => R
Attributes
- Returns
-
a
Matcher[T, R].
Method to create a named Matcher, based on the given function f.
Method to create a named Matcher, based on the given function f.
CONSIDER eliminating this method.
Type parameters
- R
-
the result type.
- T
-
the input type.
Value parameters
- f
-
a
T => MatchResult[R]. - name
-
the name for the logger to mention.
Attributes
- Returns
-
a
Matcher[T, R]based onf.
Method to match all elements of a ~.
Method to match all elements of a ~.
Type parameters
- R0
-
the MatchResult type for m0.
- R1
-
the MatchResult type for m1.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
Value parameters
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
Attributes
- Returns
-
a Matcher[T0 ~ T1, R0 ~ R1] that matches all the elements of the given ~.
Method to match any element of a ~.
Method to match any element of a ~.
Type parameters
- R
-
the MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
Value parameters
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
Attributes
- Returns
-
a Matcher[T0 ~ T1, R] that matches at least one of the elements of the given tilde.
Method to match all elements of a ~~.
Method to match all elements of a ~~.
Type parameters
- R0
-
the MatchResult type for m0.
- R1
-
the MatchResult type for m1.
- R2
-
the MatchResult type for m2.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
Value parameters
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, R0 ~ R1 ~ R2] that matches at least one of the elements of the given ~~.
Method to match any element of a Tuple3.
Method to match any element of a Tuple3.
TODO fix me
Type parameters
- R
-
the MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
- T2
-
the input type for the third Matcher.
Value parameters
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
- m2
-
the Matcher corresponding to the third element.
Attributes
- Returns
-
a Matcher[(T0, T1, T2), R] that matches at least one of the elements of the given tuple.
Creates a matcher that checks if all elements in a sequence satisfy the given matcher.
Creates a matcher that checks if all elements in a sequence satisfy the given matcher.
Value parameters
- m
-
A matcher of type
AutoMatcher[T].
Attributes
- Returns
-
A new matcher that validates sequences of type
Seq[T]. The matcher succeeds if all elements in the sequence satisfy the given matcherm, otherwise it returns a miss with the name "matchAll" and the unmatched sequence.
Creates a matcher that checks if any element in a sequence satisfies the given matcher.
Creates a matcher that checks if any element in a sequence satisfies the given matcher.
Value parameters
- m
-
A matcher of type
AutoMatcher[T].
Attributes
- Returns
-
a new matcher that takes a sequence of type
Tand returns a sequence of typeT. indicating whether at least one element in the sequence satisfies the given matcherm.
Matches the input wrapped in an Option and returns a corresponding MatchResult.
Matches the input wrapped in an Option and returns a corresponding MatchResult.
Value parameters
- ry
-
an optional value of type R to be matched
- t
-
the value of type T used when the optional value is not defined
Attributes
- Returns
-
a MatchResult of type R. Returns a Match wrapping the value when the optional is defined, otherwise returns a Miss with a message and the provided value t.
Matches the result of a Try operation and produces a MatchResult.
Matches the result of a Try operation and produces a MatchResult.
Value parameters
- ry
-
the Try instance representing a successful or failed computation
- t
-
the input value to be used in case of a failure
Attributes
- Returns
-
a MatchResult containing the success value if the Try is successful, or a failure message along with the input value if the Try is a failure
Creates a MatchResult[R] from applying a given T => Option[R] function to a value of T. NOTE this replaces the previous (1.0.12) version which had only one parametric type (T). It will be backwards-compatible but providing the types are not explicitly specified.
Creates a MatchResult[R] from applying a given T => Option[R] function to a value of T. NOTE this replaces the previous (1.0.12) version which had only one parametric type (T). It will be backwards-compatible but providing the types are not explicitly specified.
Value parameters
- f
-
A function that takes an input of type
Tand returns anOption[R]. - t
-
The input of type
Tto which the functionfis applied.
Attributes
- Returns
-
A
MatchResult[R]based on the result of applying the functionfto the inputt.
Method to match any element of a Product with two elements.
Method to match any element of a Product with two elements.
Type parameters
- P
-
the input type.
- R0
-
the first MatchResult type.
- R1
-
the second MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
Value parameters
- f
-
a function that takes a (t0, t1) and returns a P.
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
Attributes
- Returns
-
a Matcher[P, R0 ~ R1] that matches at least one of the elements of the given P.
Method to match any element of a Product with two elements.
Method to match any element of a Product with two elements.
Type parameters
- P
-
the input type.
- R
-
the MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
Value parameters
- f
-
a function that takes a (t0, t1) and returns a P.
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
Attributes
- Returns
-
a Matcher[P, R] that matches at least one of the elements of the given P.
Method to match any element of a Product with two elements.
Method to match any element of a Product with two elements.
Type parameters
- P
-
the input type.
- R0
-
the first MatchResult type.
- R1
-
the second MatchResult type.
- R2
-
the third MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
- T2
-
the input type for the third Matcher.
Value parameters
- f
-
a function that takes a (t0, t1, t3) and returns a P.
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
- m2
-
the Matcher corresponding to the third element.
Attributes
- Returns
-
a Matcher[P, R0 ~ R1 ~ R2] that matches at least one of the elements of the given P.
Method to match any element of a Product with two elements.
Method to match any element of a Product with two elements.
Type parameters
- P
-
the input type.
- R
-
the MatchResult type.
- T0
-
the input type for the first Matcher.
- T1
-
the input type for the second Matcher.
- T2
-
the input type for the third Matcher.
Value parameters
- f
-
a function that takes a (t0, t1, t3) and returns a P.
- m0
-
the Matcher corresponding to the first element.
- m1
-
the Matcher corresponding to the second element.
- m2
-
the Matcher corresponding to the third element.
Attributes
- Returns
-
a Matcher[P, R] that matches at least one of the elements of the given P.
Method to create a Matcher, of three MatchResults whose result is a P.
Method to create a Matcher, of three MatchResults whose result is a P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P.
Attributes
- Returns
-
r0 a MatchResult[T0].
Method to convert a MatchResult[~~] to a MatchResult[P].
Method to convert a MatchResult[~~] to a MatchResult[P].
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P.
Attributes
- Returns
-
t a MatchResult[T0 ~ T1 ~ T2].
Creates a MatchResult[R] from applying a given T => Try[R] function to a value of T. NOTE this replaces the previous (1.0.12) version which had only one parametric type (T). It will be backwards-compatible but providing the types are not explicitly specified.
Creates a MatchResult[R] from applying a given T => Try[R] function to a value of T. NOTE this replaces the previous (1.0.12) version which had only one parametric type (T). It will be backwards-compatible but providing the types are not explicitly specified.
Value parameters
- f
-
A function that takes an input of type
Tand returns aTryof typeR. - t
-
The input value of type
Tto be processed by the functionf.
Attributes
- Returns
-
A
MatchResultof typeR, which represents the result of matching the successful outcome off(t).
Defines a Matcher which succeeds if the input is equal to the given r. The result will be named "matches."
Defines a Matcher which succeeds if the input is equal to the given r. The result will be named "matches."
Type parameters
- R
-
both the input type and the result type.
Value parameters
- r
-
the value that must be matched.
Attributes
- Returns
-
an
AutoMatcher[R].
Defines a Matcher which succeeds only if b is true (regardless of the input to the Matcher). The result will be named "maybe."
Defines a Matcher which succeeds only if b is true (regardless of the input to the Matcher). The result will be named "maybe."
Type parameters
- R
-
both the input type and the result type.
Value parameters
- b
-
a
Booleanvalue that determines whether the result succeeds.
Attributes
- Returns
-
an
AutoMatcher[R]which succeeds ifbis true.
Method to define a named Matcher based on the function f.
Method to define a named Matcher based on the function f.
Type parameters
- R
-
the result type to both
fand the resultingMatcher. - T
-
the input type to both
fand the resultingMatcher.
Value parameters
- f
-
a function of type
T => R - name
-
the name by which the resulting
Matcherwill be identified.
Attributes
- Returns
-
a
Matcher[T, R].
Defines a Matcher which reverses the sense of this Matcher. However, an Error remains an Error. The result is named "not." TODO define this in terms of MatchResult.invert
Defines a Matcher which reverses the sense of this Matcher. However, an Error remains an Error. The result is named "not." TODO define this in terms of MatchResult.invert
Type parameters
- R
-
the result type of m.
- T
-
the input type of m.
Value parameters
- m
-
a
Matcher[T, R] - r
-
the default result value, only to be used in the even of a
Miss.
Attributes
- Returns
-
a
Matcher[T, R]which works in the opposite sense to this.
Matcher that always succeeds but whose result is an Option[R]. The result is named "opt." If the bound variable t of the resulting Matcher is null, then it will result in a Match(None).
Matcher that always succeeds but whose result is an Option[R]. The result is named "opt." If the bound variable t of the resulting Matcher is null, then it will result in a Match(None).
Type parameters
- R
-
the result type of m.
- T
-
the input type of m.
Value parameters
- m
-
a Matcher[T, R]
Attributes
- Returns
-
Matcher[T, Option of R]
Method to yield a parser af R from a regular expression.
Method to yield a parser af R from a regular expression.
Type parameters
- R
-
the underlying type of resulting Parser.
Value parameters
- p
-
a Parser[R].
- regex
-
a Regex.
Attributes
- Returns
-
a Parser[R]
Method to yield a parser af R from a String interpreted as a regular expression.
Method to yield a parser af R from a String interpreted as a regular expression.
Type parameters
- R
-
the underlying type of resulting Parser.
Value parameters
- p
-
a Parser[R].
- regex
-
the String representation of the regular expression.
Attributes
- Returns
-
a Parser[R]
Method to yield a parser af String from a regular expression.
Method to yield a parser af String from a regular expression.
Value parameters
- regex
-
a Regex.
Attributes
- Returns
-
a Parser[String]
Method to yield a parser af String from a regular expression.
Method to yield a parser af String from a regular expression.
Value parameters
- regex
-
the String representation of the regular expression.
Attributes
- Returns
-
a Parser[String]
Method to yield a Parser[Z] using the given regex, a function String=>P0 and a function P0=>Z. Typically, Z will be a case class.
Method to yield a Parser[Z] using the given regex, a function String=>P0 and a function P0=>Z. Typically, Z will be a case class.
TESTME
Type parameters
- P0
-
the type of the first member of Z.
- Z
-
the underlying type of the resulting parser.
Value parameters
- construct
-
a function P0 => Z.
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- p0
-
a Parser[P0].
- regex
-
a regular expression.
Attributes
- Returns
-
a Parser[Z].
Method to yield a Parser[Z] using the given regex, several intermediate functions, and a function (P0, P1)=>Z. Typically, Z will be a case class with two members.
Method to yield a Parser[Z] using the given regex, several intermediate functions, and a function (P0, P1)=>Z. Typically, Z will be a case class with two members.
Type parameters
- P0
-
the type of the first member of Z.
- P1
-
the type of the second member of Z.
- Z
-
the underlying type of the resulting parser.
Value parameters
- construct
-
a function (P0, P1) => Z.
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- p0
-
a Parser[P0].
- p1
-
a Parser[P1].
- regex
-
a regular expression.
Attributes
- Returns
-
a Parser[Z].
Method to yield a Parser[Z] using the given regex, several intermediate functions, and a function (P0, P1, P2)=>Z. Typically, Z will be a case class with three members.
Method to yield a Parser[Z] using the given regex, several intermediate functions, and a function (P0, P1, P2)=>Z. Typically, Z will be a case class with three members.
Type parameters
- P0
-
the type of the first member of Z.
- P1
-
the type of the second member of Z.
- P2
-
the type of the third member of Z.
- Z
-
the underlying type of the resulting parser.
Value parameters
- construct
-
a function (P0, P1, P2) => Z.
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- p0
-
a Parser[P0].
- p1
-
a Parser[P1].
- p2
-
a Parser[P2].
- regex
-
a regular expression.
Attributes
- Returns
-
a Parser[Z].
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Type parameters
- R
-
the underlying type of the resulting
Parser.
Value parameters
- p
-
a
Parser[R]. - regexGroups
-
an instance of RegexGroups.
Attributes
- Returns
-
a
Parser[R]
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Type parameters
- R
-
the underlying type of resulting Parser.
Value parameters
- group
-
an optional group index, starting at 1 (if empty, then all groups are selected).
- p
-
a Parser[R].
- regex
-
a Regex.
Attributes
- Returns
-
a Parser[R]
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Method to yield a parser af R from a regular expression and groups. There must be only one matching group.
Type parameters
- R
-
the underlying type of resulting Parser.
Value parameters
- group
-
an optional group index, starting at 1 (if empty, then all groups are selected).
- p
-
a Parser[R].
- regex
-
the String representation of the regular expression.
Attributes
- Returns
-
a Parser[R]
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Value parameters
- rg
-
an instance of RegexGroups.
Attributes
- Returns
-
a Parser[List of Strings].
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Value parameters
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- regex
-
a regular expression.
Attributes
- Returns
-
a Parser[List of Strings].
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Parser that succeeds if the input matches the given regular expression. The result of the parser is the desired List of matched Strings.
Value parameters
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- regex
-
a regular expression as a String.
Attributes
- Returns
-
a Parser[List of Strings].
Method to parse two Strings from a regular expression.
Method to parse two Strings from a regular expression.
Value parameters
- regexGroups
-
an instance of RegexGroups.
Attributes
- Returns
-
a Parser[String ~ String]
Method to parse two Strings from a regular expression.
Method to parse two Strings from a regular expression.
Value parameters
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- regex
-
a Regex.
Attributes
- Returns
-
a Parser[String ~ String]
Method to parse two Strings from a regular expression.
Method to parse two Strings from a regular expression.
Value parameters
- groups
-
a list of required group indexes, starting at 1 (if empty, then all groups are selected).
- regex
-
the String representation of the regular expression.
Attributes
- Returns
-
a Parser[String ~ String]
Method to create a Matcher, which always succeeds, of a ~ whose result is a P. This method is the inverse of tilde2.
Method to create a Matcher, which always succeeds, of a ~ whose result is a P. This method is the inverse of tilde2.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
Value parameters
- f
-
method to convert a (T0, T1) into a P.
Attributes
- Returns
-
a Matcher[T0 ~ T1, P].
Method to create a Matcher, which always succeeds, of a ~~ whose result is a P. This method is the inverse of tilde2.
Method to create a Matcher, which always succeeds, of a ~~ whose result is a P. This method is the inverse of tilde2.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
Value parameters
- f
-
method to convert a (T0, T1) into a P.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, P].
Method to rotate the order of elements in a ~~.
Method to rotate the order of elements in a ~~.
Type parameters
- T0
-
the first element type.
- T1
-
the second element type.
- T2
-
the third element type.
Attributes
- Returns
-
a Matcher[T0 ~ T1 ~ T2, T1 ~ T2 ~ T0].
Method to create a Matcher, which always succeeds, of a P whose result is a T0, based on the first element of P.
Method to create a Matcher, which always succeeds, of a P whose result is a T0, based on the first element of P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
Value parameters
- f
-
method to convert a (T0, T1) into a P (used at compile-time only).
Attributes
- Returns
-
a Matcher[P,T0]
Method to create a Matcher, which always succeeds, of a P whose result is a T1, based on the second element of P.
Method to create a Matcher, which always succeeds, of a P whose result is a T1, based on the second element of P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
Value parameters
- f
-
method to convert a (T0, T1) into a P (used at compile-time only).
Attributes
- Returns
-
a Matcher[P,T1]
Method to create a Matcher, which always succeeds, of a P whose result is a T0, based on the first element of P.
Method to create a Matcher, which always succeeds, of a P whose result is a T0, based on the first element of P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P (used at compile-time only).
Attributes
- Returns
-
a Matcher[P,T0]
Method to create a Matcher, which always succeeds, of a P whose result is a T1, based on the second element of P.
Method to create a Matcher, which always succeeds, of a P whose result is a T1, based on the second element of P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P (used at compile-time only).
Attributes
- Returns
-
a Matcher[P,T1]
Method to create a Matcher, which always succeeds, of a P whose result is a T2, based on the third element of P.
Method to create a Matcher, which always succeeds, of a P whose result is a T2, based on the third element of P.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P (used at compile-time only).
Attributes
- Returns
-
a Matcher[P,T1]
Transforms (lifts) a matcher for individual elements into a matcher for sequences of those elements.
Transforms (lifts) a matcher for individual elements into a matcher for sequences of those elements.
This method applies the provided matcher to each element of the input sequence and aggregates the results.
Value parameters
- m
-
the matcher to apply to each element of the sequence
Attributes
- Returns
-
a matcher that processes a sequence of elements and matches them based on the provided matcher
Method to convert an Option of MatchResult[R] into a MatchResult of Option[R].
Method to convert an Option of MatchResult[R] into a MatchResult of Option[R].
Type parameters
- R
-
the underlying result type.
Value parameters
- rmo
-
an optional MatchResult[R].
Attributes
- Returns
-
a MatchResult of Option[R].
Transforms (lifts) a matcher for individual elements into a matcher for sequences of those elements. The returned Matcher ensures that all elements in the input sequence are matched using the provided Matcher.
Transforms (lifts) a matcher for individual elements into a matcher for sequences of those elements. The returned Matcher ensures that all elements in the input sequence are matched using the provided Matcher.
Value parameters
- m
-
The
Matcherto apply to each element of the sequence.
Attributes
- Returns
-
A
Matcherthat matches a sequence of elements using the providedMatcher. - See also
-
MatchResult#sequenceStrict
Defines a Matcher which always succeeds and creates a Match with value r.
Defines a Matcher which always succeeds and creates a Match with value r.
NOTE: be careful not to force evaluation of r outside MatchResult.
Type parameters
- R
-
the result type.
- T
-
the input type (input is ignored).
Value parameters
- r
-
the predetermined result (call-by-name).
Attributes
- Returns
-
a
Matcher[T, R]
Method to swap the order of elements in a Tilde.
Method to swap the order of elements in a Tilde.
Type parameters
- T0
-
the first element type.
- T1
-
the second element type.
Attributes
- Returns
-
a Matcher from T0 ~ T1 to T1 ~ T0.
Method to create a Matcher, which always succeeds, of a P whose result is a ~.
Method to create a Matcher, which always succeeds, of a P whose result is a ~.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
Value parameters
- f
-
method to convert a (T0, T1) into a P.
Attributes
- Returns
-
a Matcher[P, T0 ~ T1].
Method to create a Matcher, which always succeeds, of a P whose result is a ~~.
Method to create a Matcher, which always succeeds, of a P whose result is a ~~.
Type parameters
- P
-
the product type.
- T0
-
first of the member types.
- T1
-
second of the member types.
- T2
-
third of the member types.
Value parameters
- f
-
method to convert a (T0, T1, T2) into a P.
Attributes
- Returns
-
a Matcher[P, T0 ~ T1 ~ T2].
Method to convert a MatchResult of Option[R] into a MatchResult[R]. NOTE this was formerly called sequence.
Method to convert a MatchResult of Option[R] into a MatchResult[R]. NOTE this was formerly called sequence.
Type parameters
- R
-
the underlying result type.
Value parameters
- rom
-
a MatchResult of Option[R].
Attributes
- Returns
-
a Match[R] if rom is a Match(Some(r)) otherwise a Miss.
Matcher whose success depends on the application of a function f to the input, then the application of a predicate to a control value and the result of f.
Matcher whose success depends on the application of a function f to the input, then the application of a predicate to a control value and the result of f.
CONSIDER what to do with this
Type parameters
- Q
-
the "control" type.
- R
-
the result type.
- T
-
the "input" type.
Value parameters
- f
-
a T => R.
- p
-
a predicate based on the tuple (q, r) where r is the result of applying f to t.
Attributes
- Returns
-
a
Matcher[(Q, R), T].
Matcher whose success depends on the application of a function f to the input, then the application of a predicate to a control value and the result of f.
Matcher whose success depends on the application of a function f to the input, then the application of a predicate to a control value and the result of f.
CONSIDER what to do with this
Type parameters
- Q
-
the "control" type.
- T
-
the "input" type.
Value parameters
- p
-
a predicate based on the tuple (q, r) where r is the result of applying f to t.
Attributes
- Returns
-
a
Matcher[(Q, R), T].
Concrete fields
A parser that matches a decimal number. The parser matches numbers with optional leading digits, a decimal point, and optional trailing digits.
A parser that matches a decimal number. The parser matches numbers with optional leading digits, a decimal point, and optional trailing digits.
Examples of matched patterns include:
- Whole numbers: "123"
- Floating-point numbers with leading digits: "123.456"
- Floating-point numbers without leading digits: ".456"
- Floating-point numbers with trailing decimal point: "123."
Attributes
A parser for matching floating-point numbers in string format. This parser identifies numbers with optional signs, decimal points, optional scientific notation (e/E with an optional sign), and optional floating-point type suffixes (f/F/d/D).
A parser for matching floating-point numbers in string format. This parser identifies numbers with optional signs, decimal points, optional scientific notation (e/E with an optional sign), and optional floating-point type suffixes (f/F/d/D).
The recognized pattern includes:
- Optional leading negative sign (-).
- Digits before and/or after a decimal point.
- Scientific notation with an optional positive or negative sign.
- Optional floating-point suffix (f, F, d, D).
The parsing is performed using a provided regular expression pattern.
Attributes
Attributes
- Returns
-
a Parser[BigDecimal]
Attributes
- Returns
-
a Parser[BigInt]
Attributes
- Returns
-
a Parser[Double]
Attributes
- Returns
-
a Parser[Long]
Implicits
Implicits
Implicit class MatchResultOps, which allows us to use the method tee on a MatchResult[R].
Implicit class MatchResultOps, which allows us to use the method tee on a MatchResult[R].
Type parameters
- R
-
the result type of m.
Value parameters
- rr
-
a MatchResult[R].
Attributes
Implicit class MatcherOps, which allows us to use the method :| on a Matcher[T,R].
Implicit class MatcherOps, which allows us to use the method :| on a Matcher[T,R].
Type parameters
- R
-
the result type of p.
- T
-
the input type of p.
Value parameters
- p
-
a Matcher[T,R].