Trait/Object

com.thoughtworks.feature

Glb

Related Docs: object Glb | package feature

Permalink

trait Glb[Mixin] extends Serializable

A type class that converts a mix-in type to the greatest lower bound of the components of the mix-in.

This Glb type class provides an extension method glb via implicit view, which can be import as follow:

import com.thoughtworks.feature.Glb.ops._
Author:

杨博 (Yang Bo) <[email protected]>

Source
Glb.scala
Example:
  1. Given a mix-in of two refinement components,

    type A = Option[Any] {
      def get: Immutable
    }
    type B = Option[Any] {
      def get: Iterable[String]
    }
    val ab: A with B = Some(List("cool"))

    when convert it to its greatest lower bound,

    val glbOfAB  = toAllGlbOps(ab).glb

    Then the common method should return the greatest lower bound of each components's return type.

    val result: Immutable with Iterable[String] = glbOfAB.get
    result should be(List("cool"))
Note

This Glb type class is implemented via scala.reflect.api.Types.glb, which is similar to intersection operator in Dotty, except this Glb works for refinement type only.

,

The implicit conversion toAllGlbOps must be explicitly invoked, as a workaround of https://github.com/scala/bug/issues/10671

Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Glb
  2. Serializable
  3. Serializable
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type Out >: Mixin <: Mixin

    Permalink

Abstract Value Members

  1. abstract def getClass(): Class[_]

    Permalink
    Definition Classes
    Any

Concrete Value Members

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

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to any2stringadd[Glb[Mixin]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Glb[Mixin], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to ArrowAssoc[Glb[Mixin]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

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

    Permalink
    Definition Classes
    Any
  7. def ensuring(cond: (Glb[Mixin]) ⇒ Boolean, msg: ⇒ Any): Glb[Mixin]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to Ensuring[Glb[Mixin]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  8. def ensuring(cond: (Glb[Mixin]) ⇒ Boolean): Glb[Mixin]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to Ensuring[Glb[Mixin]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: Boolean, msg: ⇒ Any): Glb[Mixin]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to Ensuring[Glb[Mixin]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean): Glb[Mixin]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to Ensuring[Glb[Mixin]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  12. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to StringFormat[Glb[Mixin]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  13. final def glb(mixin: Mixin): Out

    Permalink
    Annotations
    @inline()
  14. def hashCode(): Int

    Permalink
    Definition Classes
    Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def toString(): String

    Permalink
    Definition Classes
    Any
  17. def [B](y: B): (Glb[Mixin], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Glb[Mixin] to ArrowAssoc[Glb[Mixin]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Serializable

Inherited from Serializable

Inherited from Any

Inherited by implicit conversion any2stringadd from Glb[Mixin] to any2stringadd[Glb[Mixin]]

Inherited by implicit conversion StringFormat from Glb[Mixin] to StringFormat[Glb[Mixin]]

Inherited by implicit conversion Ensuring from Glb[Mixin] to Ensuring[Glb[Mixin]]

Inherited by implicit conversion ArrowAssoc from Glb[Mixin] to ArrowAssoc[Glb[Mixin]]

Ungrouped