object TagUsage extends App
scalaz contains a way to simulate something similar to a Haskell
newtype, where we can take an existing type, and create a new type
from it, and allow us to create new typeclass instances for our
newly created type to get different behaviors. The same thing could
be done with scala 2.10's Value Classes:
https://docs.scala-lang.org/overviews/core/value-classes.html however
one has to be very careful when using value classes, because there
are a lot of instances in which using a value class will incur a
runtime boxing/unboxing of your value, which incurs a runtime
cost. The scalaz tagged types will never cause boxing of a value
that is already AnyRef
.
- Source
- TagUsage.scala
- Alphabetic
- By Inheritance
- TagUsage
- App
- DelayedInit
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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
- val Sorted: TagOf[Sorted]
- final def args: Array[String]
- Attributes
- protected
- Definition Classes
- App
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def equalsTrue(x: Any): Boolean
- Annotations
- @unchecked()
- final val executionStart: Long
- Definition Classes
- App
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def main(args: Array[String]): Unit
- Definition Classes
- App
- def minOption[A](a: @@[List[A], Sorted]): Option[A]
- def minOption_v2[A]: (@@[List[A], Sorted]) => Option[A]
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- implicit val ord: scala.Ordering[Option[Int]]
- def sortList[A](as: List[A])(implicit arg0: scala.math.Ordering[A]): @@[List[A], Sorted]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- 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()