Maybe

zio.blocks.maybe.Maybe$package.Maybe
object Maybe

Attributes

Source
Maybe.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Maybe.type

Members list

Type members

Classlikes

final class WithFilter[A](self: Maybe[A], predicate: A => Boolean)

Attributes

Source
Maybe.scala
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

inline def absent[A]: Maybe[A]

Attributes

Source
Maybe.scala
inline def apply[A](a: A): Maybe[A]

Wraps a value in Maybe, treating null (and the Absent sentinel) as absent.

Wraps a value in Maybe, treating null (and the Absent sentinel) as absent.

Unlike present, apply collapses null/Absent to Maybe.absent. Use present when the value being wrapped is itself a Maybe that may be absent.

Attributes

Source
Maybe.scala
inline def empty[A]: Maybe[A]

Attributes

Source
Maybe.scala
def fromOption[A](opt: Option[A]): Maybe[A]

Attributes

Source
Maybe.scala
inline def present[A](a: A): Maybe[A]

Wraps a value in Maybe, preserving present-ness even for null or Absent.

Wraps a value in Maybe, preserving present-ness even for null or Absent.

A non-null/non-Absent value is returned as-is (zero allocation). A null value is wrapped as Present(null), and the Absent sentinel is wrapped as Present(Absent); both are distinguishable from Maybe.absent (the Absent singleton). This is what makes nested Maybes sound: Maybe.present(Maybe.absent) is Present(Absent), not Maybe.absent.

Special case for soundness (see Present scaladoc): if the argument is itself a Present[_], it is wrapped in an extra Present layer so that unsafeGet returns the original Present (preventing CCE when A = Present[T]). Normal present(v) for non-Present v remains zero-alloc.

Attributes

Source
Maybe.scala

Givens

Givens

given given_Conversion_Option_Maybe: [A] => given_Conversion_Option_Maybe[A]

Attributes

Source
Maybe.scala

Extensions

Extensions

extension [A](self: Maybe[A])
inline def collect[B](pf: PartialFunction[A, B]): Maybe[B]

Attributes

Source
Maybe.scala
inline def contains[A1 >: A](elem: A1): Boolean

Attributes

Source
Maybe.scala
inline def exists(p: A => Boolean): Boolean

Attributes

Source
Maybe.scala
inline def filter(p: A => Boolean): Maybe[A]

Attributes

Source
Maybe.scala
inline def filterNot(p: A => Boolean): Maybe[A]

Attributes

Source
Maybe.scala
inline def flatMap[B](f: A => Maybe[B]): Maybe[B]

Attributes

Source
Maybe.scala
inline def flatten[B](using ev: A <:< Maybe[B]): Maybe[B]

Attributes

Source
Maybe.scala
inline def fold[B](ifAbsent: => B)(ifPresent: A => B): B

Attributes

Source
Maybe.scala
inline def forall(p: A => Boolean): Boolean

Attributes

Source
Maybe.scala
inline def foreach[U](f: A => U): Unit

Attributes

Source
Maybe.scala
inline def get: A

Attributes

Source
Maybe.scala
inline def getOrElse[B >: A](default: => B): B

Attributes

Source
Maybe.scala
inline def getOrNull: A | Null

Attributes

Source
Maybe.scala
inline def isAbsent: Boolean

Attributes

Source
Maybe.scala
inline def isDefined: Boolean

Attributes

Source
Maybe.scala
inline def isEmpty: Boolean

Attributes

Source
Maybe.scala
inline def isPresent: Boolean

Attributes

Source
Maybe.scala
inline def iterator: Iterator[A]

Attributes

Source
Maybe.scala
inline def map[B](f: A => B): Maybe[B]

Attributes

Source
Maybe.scala
inline def nonEmpty: Boolean

Attributes

Source
Maybe.scala
inline def orElse[B >: A](alternative: => Maybe[B]): Maybe[B]

Attributes

Source
Maybe.scala
inline def orNull[B >: A](using ev: Null <:< B): B

Attributes

Source
Maybe.scala
inline def toLeft[X](right: => X): Either[A, X]

Attributes

Source
Maybe.scala
inline def toList: List[A]

Attributes

Source
Maybe.scala
inline def toOption: Option[A]

Attributes

Source
Maybe.scala
inline def toRight[X](left: => X): Either[X, A]

Attributes

Source
Maybe.scala
inline def toSeq: Seq[A]

Attributes

Source
Maybe.scala
inline def unzip[A1, A2](using ev: A <:< (A1, A2)): (Maybe[A1], Maybe[A2])

Attributes

Source
Maybe.scala
inline def unzip3[A1, A2, A3](using ev: A <:< (A1, A2, A3)): (Maybe[A1], Maybe[A2], Maybe[A3])

Attributes

Source
Maybe.scala
def withFilter(p: A => Boolean): WithFilter[A]

Attributes

Source
Maybe.scala
inline def zip[B](that: Maybe[B]): Maybe[(A, B)]

Attributes

Source
Maybe.scala