FP
Various utilities for functional programming.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
FP.type
Members list
Value members
Concrete methods
Method to determine if the String w was found at a valid index (i).
Method to determine if the String w was found at a valid index (i).
Value parameters
- i
-
the index found.
- w
-
the String (ignored unless there's an exception).
Attributes
- Returns
-
Success(i) if all well, else Failure(exception).
Applies a transformation function to the successful value of a Try if the value satisfies a predicate. If the predicate fails, it returns a Failure with an exception indicating the reason.
Applies a transformation function to the successful value of a Try if the value satisfies a predicate. If the predicate fails, it returns a Failure with an exception indicating the reason.
TESTME
Type parameters
- X
-
the input type of the Try.
- Y
-
the output type after applying the transformation function.
Value parameters
- f
-
a transformation function applied to the value if the predicate passes.
- p
-
a predicate function to test the successful value of the input Try.
- predicate
-
a descriptive string used in the exception message if the predicate fails. Default is "predicate".
Attributes
- Returns
-
a function that transforms a Try[X] to a Try[Y] based on the predicate and transformation function.
Converts an Option[X] to a Try[X]. If the Option is Some, it returns a Success containing the value. If the Option is None, it returns a Failure containing the provided or default Throwable.
Converts an Option[X] to a Try[X]. If the Option is Some, it returns a Success containing the value. If the Option is None, it returns a Failure containing the provided or default Throwable.
Type parameters
- X
-
the underlying type of the
OptionandTry.
Value parameters
- throwable
-
the
Throwableto use if the input isNone. Defaults toNoSuchElementException. - xo
-
the input
Option[X]to convert.
Attributes
- Returns
-
a
Try[X]representing either the success or failure of the conversion.
Method to partition an method to combine elements of Try as an Iterator.
Method to partition an method to combine elements of Try as an Iterator.
TESTME
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
an Iterator of Try[X].
Attributes
- Returns
-
a tuple of two iterators of Try[X], the first one being successes, the second one being failures.
Method to partition an method to combine elements of Try.
Method to partition an method to combine elements of Try.
TESTME
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
a Seq of Try[X].
Attributes
- Returns
-
a tuple of two Seqs of Try[X], the first one being successes, the second one being failures.
Method to yield a URL for a given resourceForClass in the classpath for C.
Method to yield a URL for a given resourceForClass in the classpath for C.
TESTME
Type parameters
- C
-
a class of the package containing the resourceForClass.
Value parameters
- resourceName
-
the name of the resourceForClass.
Attributes
- Returns
-
a Try[URL].
Method to yield a Try[URL] for a resource name and a given class.
Method to yield a Try[URL] for a resource name and a given class.
Value parameters
- clazz
-
the class, relative to which, the resource can be found (defaults to the caller's class).
- resourceName
-
the name of the resource.
Attributes
- Returns
-
a Try[URL]
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
TESTME
Type parameters
- X
-
the underlying type
Value parameters
- xys
-
an Iterator of Try[X]
Attributes
- Returns
-
a Try of Iterator[X]
Method to transform a Seq of Try[X] into a Try of Seq[X].
Method to transform a Seq of Try[X] into a Try of Seq[X].
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
a Seq of Try[X].
Attributes
- Returns
-
a Try of Seq[X].
Method to transform a Seq[Option[X]] into an Option[Seq[X]]. NOTE this is pessimistic.
Method to transform a Seq[Option[X]] into an Option[Seq[X]]. NOTE this is pessimistic.
Type parameters
- X
-
the underlying type.
Value parameters
- xos
-
a
Seq[Option[X]]].
Attributes
- Returns
-
an
Option[Seq[X]]which is defined only if all elements of the input were defined.
Method to transform a Seq of Try[X] into a Try of Seq[X].
Method to transform a Seq of Try[X] into a Try of Seq[X].
Non-fatal failures are eliminated from consideration, although each one invokes the function f. Fatal failures are retained so that the result will be a Failure.
Type parameters
- X
-
the underlying type.
Value parameters
- f
-
a function Throwable => Unit which will process each non-fatal failure.
- xys
-
a Seq of Try[X].
Attributes
- Returns
-
a Try of Seq[X].
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
TESTME
Type parameters
- X
-
the underlying type.
Value parameters
- fSuccess
-
a function of type X => Try of Option[X].
- pfFailure
-
a partial function of type Throwable => Try of Option[X].
- xys
-
an Iterable of Try[X].
Attributes
- Returns
-
a Try of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
Type parameters
- X
-
the underlying type.
Value parameters
- pfFailure
-
a partial function of type Throwable => Try of Option[X].
- xys
-
an Iterable of Try[X].
Attributes
- Returns
-
a Try of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Attempts to evaluate the provided expression and wraps the result in a Success if it is non-null. If the value is null, a Failure wrapping a NoSuchElementException with the provided message is returned.
Attempts to evaluate the provided expression and wraps the result in a Success if it is non-null. If the value is null, a Failure wrapping a NoSuchElementException with the provided message is returned.
Type parameters
- X
-
the type of the expression's result.
Value parameters
- msg
-
a message to include in the exception if the result is
null. - x
-
a lazily-evaluated expression of type
X.
Attributes
- Returns
-
a
Try[X]containingSuccess(x)ifxis non-null, orFailureifxisnull.
Method to transform a Try[X] into an Option[X]. But, unlike "toOption," a Failure can be logged.
Method to transform a Try[X] into an Option[X]. But, unlike "toOption," a Failure can be logged.
Type parameters
- X
-
the underlying type.
Value parameters
- f
-
a function to process any Exception (typically a logging function).
- xy
-
the input
Try[X].
Attributes
- Returns
-
an
Option[X].
Uncurrying for functions of arity 6.
Uncurrying for functions of arity 6.
Attributes
Uncurrying for functions of arity 7.
Uncurrying for functions of arity 7.
Attributes
Uncurrying for functions of arity 8.
Uncurrying for functions of arity 8.