Success

parsley.Success
case class Success[A](x: A) extends Result[Nothing, A]

This class is used for when a parser succeeds, and contains its result.

Type parameters

A

the type of expected success result.

Value parameters

x

the result value of the successful parse.

Attributes

Source
Result.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Result[Nothing, A]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def get: A

Returns the successful value within the result.

Returns the successful value within the result.

This is equivalent to:

result match {
 case Success(x) => x
 case _          => throw new Exception
}

Attributes

Definition Classes
Source
Result.scala
override def isFailure: Boolean

Returns true if this is a Failure, false otherwise.

Returns true if this is a Failure, false otherwise.

Attributes

Definition Classes
Source
Result.scala
override def isSuccess: Boolean

Returns true if this is a Success, false otherwise.

Returns true if this is a Success, false otherwise.

Attributes

Definition Classes
Source
Result.scala

Inherited methods

def contains[B >: A](elem: B): Boolean

Returns true if this result is a Success and its value is equal to elem (as determined by ==), returns false otherwise.

Returns true if this result is a Success and its value is equal to elem (as determined by ==), returns false otherwise.

Value parameters

elem

the element to test.

Attributes

Returns

true if this is a Success value equal to elem.

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def exists(p: A => Boolean): Boolean

Returns false if Failure or returns the result of the application of the given predicate to the Success value.

Returns false if Failure or returns the result of the application of the given predicate to the Success value.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def filterOrElse[Errʹ](p: A => Boolean, msg: => Errʹ): Result[Errʹ, A]

Returns Success with the existing value of Success if this is a Success and the given predicate p holds for the right value, or Failure(msg) if this is a Success and the given predicate p does not hold for the right value, or Failure with the existing value of Failure if this is a Failure.

Returns Success with the existing value of Success if this is a Success and the given predicate p holds for the right value, or Failure(msg) if this is a Success and the given predicate p does not hold for the right value, or Failure with the existing value of Failure if this is a Failure.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def flatMap[B, Errʹ](f: A => Result[Errʹ, B]): Result[Errʹ, B]

Returns the result of applying f to this result if it is a success.

Returns the result of applying f to this result if it is a success. Returns a failure if this result is a failure. Differs from map as f returns a result instead of just a value.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def flatten[B, Errʹ](implicit ev: A <:< Result[Errʹ, B]): Result[Errʹ, B]

Returns the nested result if this result is a success, otherwise return this failure.

Returns the nested result if this result is a success, otherwise return this failure.

Equivalent to flatMap(identity[Result[Errʹ, B]]).

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def fold[B](ferr: Nothing => B, fa: A => B): B

Returns the result of applying ferr to this result's error if this is a Failure or fa to the result stored in the Success otherwise.

Returns the result of applying ferr to this result's error if this is a Failure or fa to the result stored in the Success otherwise.

Value parameters

fa

the function to apply if this is a Success.

ferr

the function to apply if this is a Failure.

Attributes

Returns

the results of applying the function

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def forall(f: A => Boolean): Boolean

Returns true if this result is a Failure or returns the result of the application of the given predicate to the Success value.

Returns true if this result is a Failure or returns the result of the application of the given predicate to the Success value.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def foreach[U](f: A => U): Unit

Executes the procedure f if this is a Success.

Executes the procedure f if this is a Success. Otherwise, do nothing.

This is equivalent to:

result match {
 case Success(x) => f(x)
 case _          => ()
}

Value parameters

f

The side-effecting function to execute.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def getOrElse[B >: A](default: => B): B

Returns the value from this Success or the result of evaluating default if this is a Failure.

Returns the value from this Success or the result of evaluating default if this is a Failure.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def map[B](f: A => B): Result[Err, B]

Returns a Success containing the result of applying f to this result's value if this is a success.

Returns a Success containing the result of applying f to this result's value if this is a success. Otherwise, returns a failure.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def orElse[B >: A, Errʹ](alternative: => Result[Errʹ, B]): Result[Errʹ, B]

Returns this result if it is a Success, otherwise return the result of evaluating alternative.

Returns this result if it is a Success, otherwise return the result of evaluating alternative.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
def toEither: Either[Err, A]

Converts the Result into a Either where Failure maps to a Left[Err].

Converts the Result into a Either where Failure maps to a Left[Err].

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def toOption: Option[A]

Returns a Some containing the Success value if it exists or a None if this is a Failure.

Returns a Some containing the Success value if it exists or a None if this is a Failure.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def toSeq: Seq[A]

Returns a Seq containing the Success value if it exists or an empty Seq if this is a Failure.

Returns a Seq containing the Success value if it exists or an empty Seq if this is a Failure.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala
def toTry: Try[A]

Converts the Result into a Try where Failure maps to a plain Exception.

Converts the Result into a Try where Failure maps to a plain Exception.

Attributes

Since

1.7.0

Inherited from:
Result
Source
Result.scala