either

ox.either
object either

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
either.type

Members list

Type members

Classlikes

case class Fail[+E]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

inline def apply[E, A](inline body: (Label[Fail[E] | A]) ?=> A): Either[E, A]

Within an either block, allows unwrapping Either and Option values using value. The result is the right-value of an Either, or the defined-value of the Option. In case a failure is encountered (a left-value of an Either, or a None), the computation is short-circuited and the failure becomes the result.

Within an either block, allows unwrapping Either and Option values using value. The result is the right-value of an Either, or the defined-value of the Option. In case a failure is encountered (a left-value of an Either, or a None), the computation is short-circuited and the failure becomes the result.

Uses the boundary-break mechanism.

Type parameters

A

The success type.

E

The error type.

Value parameters

body

The code block, within which Eithers and Options can be unwrapped using value.

Attributes

Returns

The result - either an error, or success - represented as an Either. The error type can be set to the union of all error types that are used. In case of options, failure type is assumed to be Unit.

Example
 val v1: Either[Int, String] = ???
 val v2: Either[Long, String] = ???
 val result: Either[Int | Long, String] =
   either:
     v1.value ++ v2.value

Extensions

Extensions

extension [E, A](inline t: Either[E, A])
transparent inline def value: A

Unwrap the value of the Either, short-circuiting the computation to the enclosing either, in case this is a left-value.

Unwrap the value of the Either, short-circuiting the computation to the enclosing either, in case this is a left-value.

Attributes

extension [A](inline t: Option[A])(using b: Label[Fail[Unit]])
transparent inline def value: A

Unwrap the value of the Option, short-circuiting the computation to the enclosing either, in case this is a None.

Unwrap the value of the Option, short-circuiting the computation to the enclosing either, in case this is a None.

Attributes