Packages

  • package root
    Definition Classes
    root
  • package cats

    The cats root package contains all the trait signatures of most Scala type classes.

    The cats root package contains all the trait signatures of most Scala type classes.

    Cats type classes are implemented using the approach from the Type classes as objects and implicits article.

    For each type class, cats provides three pieces: - Its signature: a trait that is polymorphic on a type parameter. Type class traits inherit from other type classes to indicate that any implementation of the lower type class (e.g. Applicative) can also serve as an instance for the higuer type class (e.g. Functor). - Type class 'instances, which are classes and objects that implement one or more type class signatures for some specific types. Type class instances for several data types from the Java or Scala standard libraries are declared in the subpackage cats.instances. - Syntax extensions, each of which provides the methods of the type class defines as extension methods (which in Scala 2 are encoded as implicit classes) for values of any type F; given that an instance of the type class for the receiver type (this) is in the implicit scope. Symtax extensions are declared in the cats.syntax package. - A set of laws, that are also generic on the type of the class, and are only defined on the operations of the type class. The purpose of these laws is to declare some algebraic relations (equations) between Scala expressions involving the operations of the type class, and test (but not verify) that implemented instances satisfy those equations. Laws are defined in the cats-laws package.

    Although most of cats type classes are declared in this package, some are declared in other packages: - type classes that operate on base types (kind *), and their implementations for standard library types, are contained in cats.kernel, which is a different SBT project. However, they are re-exported from this package. - type classes of kind F[_, _], such as cats.arrow.Profunctor" or cats.arrow.Arrow, which are relevant for Functional Reactive Programming or optics, are declared in the cats.arrow package. - Also, those type classes that abstract over (pure or impure) functional runtime effects are declared in the cats-effect library. - Some type classes for which no laws can be provided are left out of the main road, in a small and dirty alley. These are the alleycats.

    Definition Classes
    root
  • package data
    Definition Classes
    cats
  • AndThen
  • AppFunc
  • Binested
  • BinestedBifoldable
  • BinestedBitraverse
  • BinestedInstances
  • Chain
  • Cokleisli
  • Const
  • Cont
  • ContT
  • EitherK
  • EitherT
  • Func
  • IdT
  • IndexedReaderWriterStateT
  • IndexedState
  • IndexedStateT
  • Ior
  • IorT
  • Kleisli
  • KleisliFromFunctionPartiallyApplied
  • Nested
  • NonEmptyChainOps
  • NonEmptyList
  • NonEmptyMapOps
  • NonEmptySeq
  • NonEmptySetOps
  • NonEmptyVector
  • OneAnd
  • Op
  • OptionT
  • Reader
  • ReaderWriterState
  • ReaderWriterStateT
  • RepresentableStore
  • State
  • StateT
  • Store
  • Tuple2K
  • Validated
  • Writer
  • WriterT
  • ZipList
  • ZipSeq
  • ZipStream
  • ZipVector

final case class WriterT[F[_], L, V](run: F[(L, V)]) extends Product with Serializable

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. WriterT
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new WriterT(run: F[(L, V)])

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. def ap[Z](f: WriterT[F, L, (V) ⇒ Z])(implicit F: Apply[F], L: Semigroup[L]): WriterT[F, L, Z]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer: WriterT[Option, String, Int] = WriterT.liftF(Some(123))
    scala> val wt: WriterT[Option, String, Int] = writer.tell("error")
    res0: WriterT[Option, String, Int] = WriterT(Some((error,123)))
    
    scala> val func = WriterT.liftF[Option, String, Int => List[Int]](Some(i => List(i)))
    scala> val func2 = func.tell("log")
    
    scala> wt.ap(func2)
    res1: WriterT[Option, String, List[Int]] = WriterT(Some((logerror,List(123))))
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def bimap[M, U](f: (L) ⇒ M, g: (V) ⇒ U)(implicit functorF: Functor[F]): WriterT[F, M, U]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val wr1 = WriterT.liftF[Option, String, Int](Some(123)).tell("456")
    res0: WriterT[Option, String, Int] = WriterT(Some(456,123))
    
    scala> wr1.bimap(_.toInt, _.show)
    res1: WriterT[Option, Int, String] = WriterT(Some((456,123)))
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. def compare(that: WriterT[F, L, V])(implicit Ord: Order[F[(L, V)]]): Int
  9. def contramap[Z](fn: (Z) ⇒ V)(implicit F: Contravariant[F]): WriterT[F, L, Z]
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flatMap[U](f: (V) ⇒ WriterT[F, L, U])(implicit flatMapF: FlatMap[F], semigroupL: Semigroup[L]): WriterT[F, L, U]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val wr1 = WriterT.liftF[Option, String, Int](Some(123)).tell("error")
    res0: WriterT[Option, String, Int] = WriterT(Some(error,123))
    scala> val func = (i:Int) => WriterT.liftF[Option, String, Int](Some(i * 2)).tell(i.show)
    
    scala> wr1.flatMap(func)
    res1: WriterT[Option, String, Int] = WriterT(Some((error123,246)))
  13. def foldLeft[C](c: C)(f: (C, V) ⇒ C)(implicit F: Foldable[F]): C

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(123)).tell("hi")
    scala> writer.foldLeft(456)((acc,v) => acc + v)
    res0: Int = 579
  14. def foldRight[C](lc: Eval[C])(f: (V, Eval[C]) ⇒ Eval[C])(implicit F: Foldable[F]): Eval[C]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.Eval
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(123)).tell("hi")
    scala> writer
         |    .foldRight(Eval.now(456))((v,c) => c.map(_ + v))
         |    .value
    res0: Int = 579
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def imap[Z](f: (V) ⇒ Z)(g: (Z) ⇒ V)(implicit F: Invariant[F]): WriterT[F, L, Z]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val wr1: WriterT[Option, String, Int] = WriterT.liftF(Some(123))
    scala> val wr2 = wr1.tell("log...")
    scala> wr2.imap(_ * 2)(_ / 2)
    res0: WriterT[Option, String, Int] = WriterT(Some((log...,246)))
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def listen(implicit F: Functor[F]): WriterT[F, L, (V, L)]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer: WriterT[Option, String, Int] = WriterT.liftF(Some(123))
    scala> val wt: WriterT[Option, String, Int] = writer.tell("error").tell(" log")
    res0: WriterT[Option, String, Int] = WriterT(Some((error log,123)))
    
    scala> wt.listen
    res1: WriterT[Option, String, (Int,String)] = WriterT(Some((error log,(123,error log))))
  19. def map[Z](fn: (V) ⇒ Z)(implicit functorF: Functor[F]): WriterT[F, L, Z]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val wr1: WriterT[Option, String, Int] = WriterT.liftF(None)
    scala> val wr2 = wr1.tell("error")
    res0: WriterT[Option, String, Int] = WriterT(None)
    
    scala> wr2.map(_ * 2)
    res1: WriterT[Option, String, Int] = WriterT(None)
    
    scala> val wr3: WriterT[Option, String, Int] = WriterT.liftF(Some(456))
    scala> val wr4 = wr3.tell("error")
    scala> wr4.map(_ * 2)
    res2: WriterT[Option, String, Int] = WriterT(Some((error,912)))
  20. def mapBoth[M, U](f: (L, V) ⇒ (M, U))(implicit functorF: Functor[F]): WriterT[F, M, U]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val wr1 = WriterT.liftF[Option, String, Int](Some(123)).tell("quack")
    res0: WriterT[Option, String, Int] = WriterT(Some(quack,123))
    
    scala> wr1.mapBoth((s,i) => (s + " " + s, i * 2))
    res1: WriterT[Option, String, Int] = WriterT(Some((quack quack,246)))
  21. def mapK[G[_]](f: ~>[F, G]): WriterT[G, L, V]

    Modify the context F using transformation f.

    Modify the context F using transformation f.

    Example:

    scala> import cats.data.WriterT
    scala> import cats.arrow.FunctionK
    scala> import cats.implicits._
    
    scala> val optionWriter = WriterT.liftF[Option, String, Int](Some(123)).tell("log")
    res0: WriterT[Option, String, Int](Some((log,123)))
    
    scala> def toList[A](option: Option[A]): List[A] = option.toList
    scala> val listWriter = optionWriter.mapK(FunctionK.lift(toList _))
    res1: WriterT[List, String, Int](List((log,123)))
  22. def mapWritten[M](f: (L) ⇒ M)(implicit functorF: Functor[F]): WriterT[F, M, V]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(246)).tell("error")
    res0: WriterT[Option, String, Int] = WriterT(Some((error,246)))
    
    scala> writer.mapWritten(i => List(i))
    res1: WriterT[Option, List[String], Int] = WriterT(Some((List(error),246)))
  23. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. def reset(implicit monoidL: Monoid[L], functorF: Functor[F]): WriterT[F, L, V]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(123)).tell("error")
    scala> writer.reset
    res0: WriterT[Option, String, Int] = WriterT(Some((,123)))
  27. val run: F[(L, V)]
  28. def show(implicit F: Show[F[(L, V)]]): String

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(456)).tell("log...")
    scala> writer.show
    res0: String = Some((log...,456))
  29. def swap(implicit functorF: Functor[F]): WriterT[F, V, L]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(123)).tell("log")
    scala> writer.swap
    res0: WriterT[Option, Int, String] = WriterT(Some((123,log)))
  30. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  31. def tell(l: L)(implicit functorF: Functor[F], semigroupL: Semigroup[L]): WriterT[F, L, V]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, List[String], Int](Some(123))
    scala> writer.tell(List("a","b","c")).tell(List("d","e","f"))
    res0: WriterT[Option, List[String], Int] = WriterT(Some((List(a, b, c, d, e, f),123)))
  32. def traverse[G[_], V1](f: (V) ⇒ G[V1])(implicit F: Traverse[F], G: Applicative[G]): G[WriterT[F, L, V1]]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer = WriterT.liftF[Option, String, Int](Some(123)).tell("hi")
    scala> writer.traverse[List,Int](i => List(i))
    res0: List[WriterT[Option, String, Int]] = List(WriterT(Some((hi,123))))
  33. def value(implicit functorF: Functor[F]): F[V]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer: WriterT[Option, List[String], Int] = WriterT.liftF(Some(123))
    scala> val wt: WriterT[Option, List[String], Int] = writer.tell(List("error"))
    res0: WriterT[Option, List[String], Int] = WriterT(Some((List(error),123)))
    
    scala> wt.value
    res1: Option[Int] = Some(123)
  34. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  37. def written(implicit functorF: Functor[F]): F[L]

    Example:

    Example:

    scala> import cats.data.WriterT
    scala> import cats.implicits._
    
    scala> val writer: WriterT[Option, List[String], Int] = WriterT.liftF(Some(123))
    scala> writer.tell(List("a","b","c")).written.getOrElse(Nil)
    res0: List[String] = List(a, b, c)

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped