Eithered

name.rayrobdod.stringContextParserCombinator.typeclass.Eithered
See theEithered companion trait
object Eithered

Predefined implicit implementations of Eithered and methods to create new Eithereds

Attributes

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

Members list

Value members

Concrete methods

def apply[A, B, Z](leftFn: A => Z, rightFn: B => Z): Eithered[A, B, Z]

Constructs an Eithered from a set of functions corresponding to each of Eithered's methods

Constructs an Eithered from a set of functions corresponding to each of Eithered's methods

Attributes

Source
Eithered.scala
def discriminatedUnion[A, B]: Eithered[A, B, Either[A, B]]

An Eithered that wraps the value in a scala.Either

An Eithered that wraps the value in a scala.Either

Attributes

Example

In the following interpolator, even digits are placed in a Left while odd digits are placed in a Right

import name.rayrobdod.stringContextParserCombinator.Interpolator.idInterpolators._
import name.rayrobdod.stringContextParserCombinator.typeclass.Eithered
val evenOdd:Interpolator[Either[Char, Char]] = charIn("02468").orElse(charIn("13579"))(using Eithered.discriminatedUnion)
evenOdd.interpolate(StringContext("4"), Nil) // Left(4): Either[Char, Char]
evenOdd.interpolate(StringContext("7"), Nil) // Right(7): Either[Char, Char]
Source
Eithered.scala

Givens

Inherited givens

given anyUnit[A, Z](using ev: Optionally[A, Z]): Eithered[A, Unit, Z]

Attributes

Inherited from:
VersionSpecificEithered (hidden)
Source
VersionSpecificEithered.scala
given generic[A, B]: Eithered[A, B, A | B]

The fallback Eithered; creates a union type of the two component types.

The fallback Eithered; creates a union type of the two component types.

Since the union of a type with itself is equivalent to that same type, if this Eithered is used for two parsers of the same type, then the result is a parser of that type.

Attributes

Inherited from:
LowPrioEithered (hidden)
Source
VersionSpecificEithered.scala
given unitAny[B, Z](using ev: Optionally[B, Z]): Eithered[Unit, B, Z]

Attributes

Inherited from:
VersionSpecificEithered (hidden)
Source
VersionSpecificEithered.scala

Attributes

Inherited from:
VersionSpecificEithered (hidden)
Source
VersionSpecificEithered.scala