com.gensler.scalavro.util

Union

object Union extends UnionTypeHelpers

Provides a facility for specifying unboxed union types of arbitrary ordinality in the Scala type system.

This clever technique was proposed by Miles Sabin: http://chuusai.com/2011/06/09/scala-union-types-curry-howard

Usage:

Example:
  1. import com.gensler.scalavro.util.Union._
    
    type UnionISB = union [Int] #or [String] #or [Boolean]
    
    def unionPrint[T : prove [UnionISB] #containsType](t: T) =
      t match {
        case i: Int     => println(i)
        case s: String  => println(s)
        case b: Boolean => println(b)
      }
    
    unionPrint(true) // "true"
    unionPrint(55)   // 55
Linear Supertypes
UnionTypeHelpers, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Union
  2. UnionTypeHelpers
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Disjunction[A] extends AnyRef

    Definition Classes
    UnionTypeHelpers
  2. sealed trait not[-A] extends AnyRef

    Definition Classes
    UnionTypeHelpers
  3. type prove[U] = AnyRef { type containsType[X] = <:<[com.gensler.scalavro.util.Union.not[com.gensler.scalavro.util.Union.not[X]],U] }

  4. type union[A] = AnyRef { ... /* 2 definitions in type refinement */ }

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def combine[C, T](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[C], arg1: scala.reflect.api.JavaUniverse.TypeTag[T]): Union[not[C with not[T]]]

    Returns a new Union constructed from a conjunction of Union.

    INTERNAL API

    Returns a new Union constructed from a conjunction of Union.not[_] types and an additional type to add to the conjunction.

    Given C = not[A] with not[B] and T, this method returns a Union wrapping the equivalent of union[A] #or [B] #or [T].

    A TypeTag describing the conjunction of negations unwrapped from the underlying union type is readily available via its underlyingConjunctionTag method.

    Usage:

    val binaryUnion = new Union[union [Int] #or [String]]
    
    val ternaryUnion = Union.combine(
      binaryUnion.underlyingConjunctionTag,
      typeTag[Boolean]
    )
    
    ternaryUnion.typeMembers // yields Vector(Int, String, Boolean)
    C

    the starting conjunction of negations

    T

    the type to add to the conjunction before negation

    Attributes
    protected[com.gensler.scalavro]
  9. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

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

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  19. def toString(): String

    Definition Classes
    AnyRef → Any
  20. def unary[T](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Union[not[not[T]]]

    Constructs a new unary union instance with the supplied type as its only member type.

  21. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from UnionTypeHelpers

Inherited from AnyRef

Inherited from Any

Ungrouped