abstract class NewtypeK[Src[_]] extends NewtypeTraitK[Src]
For building newtypes over types that have an invariant type parameter (higher-kinded types).
Example:
// Only needed for type-class derivation import cats._ import cats.implicits._ type Nel[A] = Nel.Type[A] object Nel extends NewtypeK[List] { def apply[A](head: A, tail: A*): Nel[A] = unsafeCoerce(head :: tail.toList) def unapply[F[_], A](list: F[A])( implicit ev: F[A] =:= Nel[A] ): Some[(A, List[A])] = { val l = value(list) Some((l.head, l.tail)) } implicit def eq[A: Eq]: Eq[Nel[A]] = derive implicit val traverse: Traverse[Nel] = deriveK implicit val monad: Monad[Nel] = deriveK }
NOTE: the type-parameter is invariant. See NewtypeCovariantK for working with covariant type parameters.
- Source
- NewtypeK.scala
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- NewtypeK
- NewtypeTraitK
- NewEncodingK
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Instance Constructors
- new NewtypeK()
Type Members
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: