Package

com.softwaremill

tagging

Permalink

package tagging

Tag instances with arbitrary types. The tags are usually empty traits. Tags have no runtime overhead and are only used at compile-time for additional type safety.

For example:

class Berry()

trait Black
trait Blue

val berry = new Berry()
val blackBerry: Berry @@ Black = berry.taggedWith[Black]
val blueBerry: Berry @@ Blue = berry.taggedWith[Blue]

// compile error: val anotherBlackBerry: Berry @@ Black = blueBerry

Original idea by Miles Sabin, see: https://gist.github.com/milessabin/89c9b47a91017973a35f

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. tagging
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type @@[+T, +U] = T with Tag[U]

    Permalink
  2. implicit final class AndTagger[T, U] extends AnyVal

    Permalink
  3. implicit final class AndTaggingF[F[_], T, U] extends AnyVal

    Permalink
  4. implicit final class AndTaggingF2[F1[_], F2[_], T, U] extends AnyVal

    Permalink
  5. implicit final class AndTaggingMapKey[M[_, _], K, A, V] extends AnyVal

    Permalink
  6. trait AnyTypeclassTaggingCompat extends AnyRef

    Permalink
  7. implicit final class Function2Tagger[A, B, C] extends AnyVal

    Permalink
  8. implicit final class Function3Tagger[A, B, C, D] extends AnyVal

    Permalink
  9. implicit final class Function4Tagger[A, B, C, D, E] extends AnyVal

    Permalink
  10. implicit final class FunctionTagger[A, B] extends AnyVal

    Permalink
  11. trait Tag[+U] extends Any

    Permalink
  12. type Tagged[+T, +U] = T with Tag[U]

    Permalink
  13. implicit final class Tagger[T] extends AnyVal

    Permalink
  14. implicit final class TaggingF[F[_], T] extends AnyVal

    Permalink
  15. implicit final class TaggingF2[F1[_], F2[_], T] extends AnyVal

    Permalink
  16. implicit final class TaggingMapKey[M[_, _], K, V] extends AnyVal

    Permalink
  17. trait TypeclassTaggingCompat[Typeclass[_]] extends AnyRef

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped