All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sutils.fp.ImplicitOptionOps.scala Maven / Gradle / Ivy

package sutils.fp

import scalaz.{ -\/, \/, \/- }

/** Implicits that add a DSL for working with the Option type. */
object ImplicitOptionOps {

  /** Converts an Option[T] into a disjunction of Unit and T. */
  implicit class OptionToDisjunction[T](private val x: Option[T]) extends AnyVal {
    @inline def toOr: \/[Unit, T] =
      x match {
        case None => -\/(())
        case Some(value) => \/-(value)
      }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy