Class/Object

kantan.codecs

Result

Related Docs: object Result | package codecs

Permalink

sealed abstract class Result[+F, +S] extends Product with Serializable

Represents the result of a decode operation

This is very similar to Either, with a few more bells and whistles and a more specific type. It's also much more convenient to use in for-comprehensions, as it has proper map and flatMap methods.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Result
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def canEqual(that: Any): Boolean

    Permalink
    Definition Classes
    Equals
  2. abstract def ensure[FF >: F](fail: ⇒ FF)(f: (S) ⇒ Boolean): Result[FF, S]

    Permalink

    Turns any success whose underlying value doesn't validate the specified predicate into a failure.

    Turns any success whose underlying value doesn't validate the specified predicate into a failure.

    This is useful when not all successes are interesting. One might receive, for example, a success containing an int, but need to further reduce its domain to positive ints and turn any other into a failure.

  3. abstract def exists(f: (S) ⇒ Boolean): Boolean

    Permalink

    Returns the result of applying the specified predicate to the underlying value if a success, false otherwise.

  4. abstract def flatMap[FF >: F, SS](f: (S) ⇒ Result[FF, SS]): Result[FF, SS]

    Permalink
  5. abstract def fold[A](ff: (F) ⇒ A, fs: (S) ⇒ A): A

    Permalink
  6. abstract def forall(f: (S) ⇒ Boolean): Boolean

    Permalink

    Returns the result of applying the specified predicate to the underlying value if a success, false otherwise.

  7. abstract def foreach(f: (S) ⇒ Unit): Unit

    Permalink

    Applies the specified procedure on the underlying value if a success, does nothing otherwise.

    Applies the specified procedure on the underlying value if a success, does nothing otherwise.

    This is useful when one wants to have side-effects that depend on the success' value - print it, for example.

  8. abstract def get: S

    Permalink

    Returns the underlying value if a success, throws an exception otherwise.

    Returns the underlying value if a success, throws an exception otherwise.

    Other value retrieval methods, such as getOrElse or valueOr, should almost always be preferred.

  9. abstract def getOrElse[SS >: S](default: ⇒ SS): SS

    Permalink

    Returns the underlying value if a success, the specified default value otherwise.

    Returns the underlying value if a success, the specified default value otherwise.

    This is useful when one needs to provide a default value in case of a failure.

  10. abstract def isSuccess: Boolean

    Permalink

    Returns true if the result is a success.

  11. abstract def leftFlatMap[FF, SS >: S](f: (F) ⇒ Result[FF, SS]): Result[FF, SS]

    Permalink
  12. abstract def leftMap[FF](f: (F) ⇒ FF): Result[FF, S]

    Permalink
  13. abstract def map[SS](f: (S) ⇒ SS): Result[F, SS]

    Permalink
  14. abstract def orElse[FF >: F, SS >: S](default: ⇒ Result[FF, SS]): Result[FF, SS]

    Permalink

    Returns the specified default value if a failure, does nothing otherwise.

  15. abstract def productArity: Int

    Permalink
    Definition Classes
    Product
  16. abstract def productElement(n: Int): Any

    Permalink
    Definition Classes
    Product
  17. abstract def recover[SS >: S](pf: PartialFunction[F, SS]): Result[F, SS]

    Permalink

    Turns any failure whose value is defined for specified partial function into a success with the corresponding value.

    Turns any failure whose value is defined for specified partial function into a success with the corresponding value.

    This is useful when some error conditions are actually valid answers - one could imagine, for instance, that failure to parse a boolean could be turned into a successful parsing of false.

  18. abstract def recoverWith[SS >: S, FF >: F](pf: PartialFunction[F, Result[FF, SS]]): Result[FF, SS]

    Permalink

    Turns any failure whose value is defined for specified partial function into the corresponding value.

    Turns any failure whose value is defined for specified partial function into the corresponding value.

    This is useful when some error conditions have fallback solutions - one could imagine, for instance, that failure to parse a file because it does not exist can be retried on a secondary possible location for the file.

  19. abstract def toEither: Either[F, S]

    Permalink

    Turns a success into a Right and a failure into a Left.

  20. abstract def toList: List[S]

    Permalink

    Turns a success into a singleton list and a failure into an empty list.

  21. abstract def toOption: Option[S]

    Permalink

    Turns a success into a Some and a failure into a None.

  22. abstract def valueOr[SS >: S](f: (F) ⇒ SS): SS

    Permalink

    Returns the underlying value if a success, the result of applying the specified function to the failure value otherwise.

    Returns the underlying value if a success, the result of applying the specified function to the failure value otherwise.

    This is typically useful when one needs to provide a default value that depends on how an operation failed.

    See also

    recover, recoverWith

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def biFlatMap[FF >: F, SS >: S](f: (FF) ⇒ Result[FF, SS], g: (SS) ⇒ Result[FF, SS]): Result[FF, SS]

    Permalink
  6. def bimap[FF, SS](f: (F) ⇒ FF, s: (S) ⇒ SS): Result[FF, SS]

    Permalink
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def foldLeft[A](acc: A)(f: (A, S) ⇒ A): A

    Permalink
  12. def foldRight[A](acc: A)(f: (S, A) ⇒ A): A

    Permalink
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. def isFailure: Boolean

    Permalink

    Returns true if the result is a failure.

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. def productIterator: Iterator[Any]

    Permalink
    Definition Classes
    Product
  21. def productPrefix: String

    Permalink
    Definition Classes
    Product
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped