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
Ordering
- Alphabetic
- By Inheritance
Inherited
- NewtypeCovariantK
- NewtypeCovariantTraitK
- NewEncodingK
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Instance Constructors
- new NewtypeCovariantK()
Type Members
- type Base[+A] = Any { type NewType$base }
- Definition Classes
- NewtypeCovariantTraitK → NewEncodingK
- implicit final class Ops[A] extends AnyRef
- Definition Classes
- NewEncodingK
- trait Tag extends Any
- Definition Classes
- NewEncodingK
- abstract type Type[+A] <: Base[A] with Tag
- Definition Classes
- NewtypeCovariantTraitK → NewEncodingK
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def derive[F[_], A](implicit ev: F[Src[A]]): F[Type[A]]
- Attributes
- protected
- Definition Classes
- NewEncodingK
- Annotations
- @inline()
- final def deriveK[F[_[_]]](implicit ev: F[Src]): F[Type]
- Attributes
- protected
- Definition Classes
- NewEncodingK
- Annotations
- @inline()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- implicit final def extractor[A]: Aux[Type[A], Src[A]]
- Definition Classes
- NewEncodingK
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- implicit def typeName[A](implicit arg0: TypeInfo[A]): TypeInfo[Type[A]]
- Definition Classes
- NewEncodingK
- final def unsafeCoerce[A](value: Src[A]): Type[A]
- Attributes
- protected
- Definition Classes
- NewEncodingK
- Annotations
- @inline()
- final def value[A](x: Type[A]): Src[A]
- Definition Classes
- NewEncodingK
- Annotations
- @inline()
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Macro-free helpers for defining newtypes in Scala.
Links: