Packages

c

monix.newtypes

NewtypeCovariantK

abstract class NewtypeCovariantK[Src[+_]] extends NewtypeCovariantTraitK[Src]

For building newtypes over types that have a covariant type parameter (higher-kinded types).

Example:

// Only needed for type-class derivation
import cats._
import cats.implicits._

type NonEmptyList[A] = NonEmptyList.Type[A]

object NonEmptyList extends NewtypeCovariantK[List] {
  def apply[A](head: A, tail: A*): NonEmptyList[A] =
    unsafeCoerce(head :: tail.toList)

  def unapply[F[_], A](list: F[A])(
    implicit ev: F[A] =:= NonEmptyList[A]
  ): Some[(A, List[A])] = {
    val l = value(list)
    Some((l.head, l.tail))
  }

  implicit def eq[A: Eq]: Eq[NonEmptyList[A]] =
    derive
  implicit val traverse: Traverse[NonEmptyList] =
    deriveK
  implicit val monad: Monad[NonEmptyList] =
    deriveK
}

NOTE: the type-parameter is covariant.

Source
NewtypeK.scala
See also

NewtypeK for working with invariance.

Linear Supertypes
NewtypeCovariantTraitK[Src], NewEncodingK[Src], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NewtypeCovariantK
  2. NewtypeCovariantTraitK
  3. NewEncodingK
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new NewtypeCovariantK()

Type Members

  1. type Base[+A] = Any { type NewType$base }
    Definition Classes
    NewtypeCovariantTraitK → NewEncodingK
  2. implicit final class Ops[A] extends AnyRef
    Definition Classes
    NewEncodingK
  3. trait Tag extends Any
    Definition Classes
    NewEncodingK
  4. abstract type Type[+A] <: Base[A] with Tag
    Definition Classes
    NewtypeCovariantTraitK → NewEncodingK

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  6. final def derive[F[_], A](implicit ev: F[Src[A]]): F[Type[A]]
    Attributes
    protected
    Definition Classes
    NewEncodingK
    Annotations
    @inline()
  7. final def deriveK[F[_[_]]](implicit ev: F[Src]): F[Type]
    Attributes
    protected
    Definition Classes
    NewEncodingK
    Annotations
    @inline()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. implicit final def extractor[A]: Aux[Type[A], Src[A]]
    Definition Classes
    NewEncodingK
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  17. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. implicit def typeName[A](implicit arg0: TypeInfo[A]): TypeInfo[Type[A]]
    Definition Classes
    NewEncodingK
  20. final def unsafeCoerce[A](value: Src[A]): Type[A]
    Attributes
    protected
    Definition Classes
    NewEncodingK
    Annotations
    @inline()
  21. final def value[A](x: Type[A]): Src[A]
    Definition Classes
    NewEncodingK
    Annotations
    @inline()
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from NewtypeCovariantTraitK[Src]

Inherited from NewEncodingK[Src]

Inherited from AnyRef

Inherited from Any

Ungrouped