Package

cats

data

Permalink

package data

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

Type Members

  1. sealed abstract class AndThen[-T, +R] extends (T) ⇒ R with Product with Serializable

    Permalink

    A function type of a single input that can do function composition (via andThen and compose) in constant stack space with amortized linear time application (in the number of constituent functions).

    A function type of a single input that can do function composition (via andThen and compose) in constant stack space with amortized linear time application (in the number of constituent functions).

    Example:

    val seed = AndThen((x: Int) => x + 1))
    val f = (0 until 10000).foldLeft(seed)((acc, _) => acc.andThen(_ + 1))
    
    // This should not trigger stack overflow ;-)
    f(0)

    This can be used to build stack safe data structures that make use of lambdas. The perfect candidates for usage with AndThen are the data structures using a signature like this (where F[_] is a monadic type):

    A => F[B]

    As an example, if we described this data structure, the naive solution for that map is stack unsafe:

    case class Resource[F[_], A, B](
      acquire: F[A],
      use: A => F[B],
      release: A => F[Unit]) {
    
      def flatMap[C](f: B => C)(implicit F: Functor[F]): Resource[F, A, C] = {
        Resource(
          ra.acquire,
          // Stack Unsafe!
          a => ra.use(a).map(f),
          ra.release)
      }
    }

    To describe a flatMap operation for this data type, AndThen can save the day:

    def flatMap[C](f: B => C)(implicit F: Functor[F]): Resource[F, A, C] = {
      Resource(
        ra.acquire,
        AndThen(ra.use).andThen(_.map(f)),
        ra.release)
    }
  2. sealed abstract class AppFunc[F[_], A, B] extends Func[F, A, B]

    Permalink

    An implementation of Func that's specialized to Applicative.

  3. final case class Binested[F[_, _], G[_], H[_], A, B](value: F[G[A], H[B]]) extends Product with Serializable

    Permalink

    Compose a two-slot type constructor F[_, _] with two single-slot type constructors G[_] and H[_], resulting in a two-slot type constructor with respect to the inner types.

    Compose a two-slot type constructor F[_, _] with two single-slot type constructors G[_] and H[_], resulting in a two-slot type constructor with respect to the inner types. For example, List and Option both have Functor instances, and Either has a Bifunctor instance. Therefore, Binested[Either, List, Option, ?, ?] has a Bifunctor instance as well:

    scala> import cats.Bifunctor
    scala> import cats.data.Binested
    scala> import cats.implicits._
    scala> val eitherListOption: Either[List[Int], Option[String]] = Right(Some("cats"))
    scala> val f: Int => String = _.toString
    scala> val g: String => String = _ + "-bifunctor"
    scala> val binested = Binested(eitherListOption)
    scala> val bimapped = Bifunctor[Binested[Either, List, Option, ?, ?]].bimap(binested)(f, g).value
    res0: Either[List[String], Option[String]] = Right(Some("cats-bifunctor"))
  4. sealed abstract class BinestedBifoldable[F[_, _], G[_], H[_]] extends Bifoldable[[δ$12$, ε$13$]Binested[F, G, H, δ$12$, ε$13$]]

    Permalink
  5. sealed abstract class BinestedBitraverse[F[_, _], G[_], H[_]] extends BinestedBifoldable[F, G, H] with Bitraverse[[δ$14$, ε$15$]Binested[F, G, H, δ$14$, ε$15$]]

    Permalink
  6. trait BinestedInstances extends BinestedInstances0

    Permalink
  7. trait BinestedInstances0 extends AnyRef

    Permalink
  8. sealed abstract class Chain[+A] extends AnyRef

    Permalink

    Trivial catenable sequence.

    Trivial catenable sequence. Supports O(1) append, and (amortized) O(1) uncons, such that walking the sequence via N successive uncons steps takes O(N).

  9. final case class Cokleisli[F[_], A, B](run: (F[A]) ⇒ B) extends Product with Serializable

    Permalink

    Represents a function F[A] => B.

  10. final case class Const[A, B](getConst: A) extends Product with Serializable

    Permalink

    Const is a phantom type, it does not contain a value of its second type parameter B Const can be seen as a type level version of Function.const[A, B]: A => B => A

  11. sealed abstract class ContT[M[_], A, +B] extends Serializable

    Permalink

    This is a continuation transformer based on the ContT in the Haskell package Control.Monad.Cont

    This is a continuation transformer based on the ContT in the Haskell package Control.Monad.Cont

    This is reasonably straight-forward except that to make a tailRecM implementation we leverage the Defer type class to obtain stack-safety.

  12. final case class EitherK[F[_], G[_], A](run: Either[F[A], G[A]]) extends Product with Serializable

    Permalink

    F on the left and G on the right of scala.util.Either.

    F on the left and G on the right of scala.util.Either.

    run

    The underlying scala.util.Either.

  13. type EitherNec[+E, +A] = Either[NonEmptyChain[E], A]

    Permalink
  14. type EitherNel[+E, +A] = Either[NonEmptyList[E], A]

    Permalink
  15. type EitherNes[E, +A] = Either[NonEmptySet[E], A]

    Permalink
  16. final case class EitherT[F[_], A, B](value: F[Either[A, B]]) extends Product with Serializable

    Permalink

    Transformer for Either, allowing the effect of an arbitrary type constructor F to be combined with the fail-fast effect of Either.

    Transformer for Either, allowing the effect of an arbitrary type constructor F to be combined with the fail-fast effect of Either.

    EitherT[F, A, B] wraps a value of type F[Either[A, B]]. An F[C] can be lifted in to EitherT[F, A, C] via EitherT.right, and lifted in to a EitherT[F, C, B] via EitherT.left.

  17. sealed abstract class Func[F[_], A, B] extends AnyRef

    Permalink

    Func is a function A => F[B].

    Func is a function A => F[B].

    See: The Essence of the Iterator Pattern

  18. type IRWST[F[_], E, L, SA, SB, A] = IndexedReaderWriterStateT[F, E, L, SA, SB, A]

    Permalink
  19. final case class IdT[F[_], A](value: F[A]) extends Product with Serializable

    Permalink

    IdT[F[_], A] is the identity monad transformer.

  20. final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A] extends Serializable

    Permalink

    Represents a stateful computation in a context F[_], from state SA to state SB, with an initial environment E, an accumulated log L and a result A.

    Represents a stateful computation in a context F[_], from state SA to state SB, with an initial environment E, an accumulated log L and a result A.

    In other words, it is a pre-baked stack of ReaderT[F, E, A], WriterT[F, L, A] and IndexedStateT[F, SA, SB, A].

  21. type IndexedState[S1, S2, A] = IndexedStateT[Eval, S1, S2, A]

    Permalink
  22. final class IndexedStateT[F[_], SA, SB, A] extends Serializable

    Permalink

    IndexedStateT[F, SA, SB, A] is a stateful computation in a context F yielding a value of type A.

    IndexedStateT[F, SA, SB, A] is a stateful computation in a context F yielding a value of type A. The state transitions from a value of type SA to a value of type SB.

    Note that for the SA != SB case, this is an indexed monad. Indexed monads are monadic type constructors annotated by an additional type for effect tracking purposes. In this case, the annotation tracks the initial state and the resulting state.

    Given IndexedStateT[F, S, S, A], this yields the StateT[F, S, A] monad.

  23. sealed abstract class Ior[+A, +B] extends Product with Serializable

    Permalink

    Represents a right-biased disjunction that is either an A, or a B, or both an A and a B.

    Represents a right-biased disjunction that is either an A, or a B, or both an A and a B.

    An instance of A Ior B is one of:

    A Ior B is similar to scala.util.Either[A, B], except that it can represent the simultaneous presence of an A and a B. It is right-biased so methods such as map and flatMap operate on the B value. Some methods, like flatMap, handle the presence of two Both values using a Semigroup[A], while other methods, like toEither, ignore the A value in a Both.

    A Ior B is isomorphic to Either[Either[A, B], (A, B)], but provides methods biased toward B values, regardless of whether the B values appear in a Right or a Both. The isomorphic scala.util.Either form can be accessed via the unwrap method.

  24. type IorNec[+B, +A] = Ior[NonEmptyChain[B], A]

    Permalink
  25. type IorNel[+B, +A] = Ior[NonEmptyList[B], A]

    Permalink
  26. type IorNes[B, +A] = Ior[NonEmptySet[B], A]

    Permalink
  27. final case class IorT[F[_], A, B](value: F[Ior[A, B]]) extends Product with Serializable

    Permalink
  28. final case class Kleisli[F[_], A, B](run: (A) ⇒ F[B]) extends Product with Serializable

    Permalink

    Represents a function A => F[B].

  29. final case class Nested[F[_], G[_], A](value: F[G[A]]) extends Product with Serializable

    Permalink

    Similar to cats.data.Tuple2K, but for nested composition.

    Similar to cats.data.Tuple2K, but for nested composition.

    For instance, since both List and Option have a Functor, then so does List[Option[_]]. This is represented by this data type via the instantiation Nested[List, Option, ?].

    scala> import cats.Functor
    scala> import cats.data.Nested
    scala> import cats.implicits._
    scala> val listOption: List[Option[Int]] = List(Some(1), None)
    scala> val f: Int => String = i => (i * 2).toString
    scala> Functor[List].map(listOption)(opt => opt.map(f))
    res0: List[Option[String]] = List(Some(2), None)
    scala> val nested: Nested[List, Option, Int] = Nested(listOption)
    scala> val result: Nested[List, Option, String] = Functor[Nested[List, Option, ?]].map(nested)(f)
    scala> result.value
    res1: List[Option[String]] = List(Some(2), None)
  30. type NonEmptyChain[+A] = Type[A]

    Permalink
  31. final class NonEmptyChainOps[A] extends AnyVal

    Permalink
  32. final case class NonEmptyList[+A](head: A, tail: List[A]) extends Product with Serializable

    Permalink

    A data type which represents a non empty list of A, with single element (head) and optional structure (tail).

  33. type NonEmptyMap[K, +A] = data.NonEmptyMapImpl.Type[K, A]

    Permalink
  34. sealed class NonEmptyMapOps[K, A] extends AnyRef

    Permalink
  35. type NonEmptySet[A] = data.NonEmptySetImpl.Type[A]

    Permalink
  36. sealed class NonEmptySetOps[A] extends AnyRef

    Permalink
  37. type NonEmptyStream[A] = OneAnd[Stream, A]

    Permalink
  38. final class NonEmptyVector[+A] extends AnyVal

    Permalink

    A data type which represents a Vector guaranteed to contain at least one element.

    A data type which represents a Vector guaranteed to contain at least one element.
    Note that the constructor is private to prevent accidental construction of an empty NonEmptyVector. However, due to https://issues.scala-lang.org/browse/SI-6601, on Scala 2.10, this may be bypassed due to a compiler bug.

  39. final case class OneAnd[F[_], A](head: A, tail: F[A]) extends Product with Serializable

    Permalink

    A data type which represents a single element (head) and some other structure (tail).

    A data type which represents a single element (head) and some other structure (tail). As we have done in package.scala, this can be used to represent a Stream which is guaranteed to not be empty:

    type NonEmptyStream[A] = OneAnd[Stream, A]
  40. final case class Op[Arr[_, _], A, B](run: Arr[B, A]) extends Product with Serializable

    Permalink

    The dual category of some other category, Arr.

  41. final case class OptionT[F[_], A](value: F[Option[A]]) extends Product with Serializable

    Permalink

    OptionT[F[_], A] is a light wrapper on an F[Option[A]] with some convenient methods for working with this nested structure.

    OptionT[F[_], A] is a light wrapper on an F[Option[A]] with some convenient methods for working with this nested structure.

    It may also be said that OptionT is a monad transformer for Option.

    For more information, see the documentation.

  42. type RWS[E, L, S, A] = IndexedReaderWriterStateT[Eval, E, L, S, S, A]

    Permalink
  43. type RWST[F[_], E, L, S, A] = IndexedReaderWriterStateT[F, E, L, S, S, A]

    Permalink
  44. type Reader[A, B] = Kleisli[Id, A, B]

    Permalink
  45. type ReaderT[F[_], A, B] = Kleisli[F, A, B]

    Permalink
  46. type ReaderWriterState[E, L, S, A] = IndexedReaderWriterStateT[Eval, E, L, S, S, A]

    Permalink
  47. type ReaderWriterStateT[F[_], E, L, S, A] = IndexedReaderWriterStateT[F, E, L, S, S, A]

    Permalink

    Represents a stateful computation in a context F[_], over state S, with an initial environment E, an accumulated log L and a result A.

  48. final case class RepresentableStore[F[_], S, A](fa: F[A], index: S)(implicit R: Aux[F, S]) extends Product with Serializable

    Permalink

    A generalisation of the Store comonad, for any Representable functor.

    A generalisation of the Store comonad, for any Representable functor. Store is the dual of State

  49. type State[S, A] = IndexedStateT[Eval, S, S, A]

    Permalink
  50. type StateT[F[_], S, A] = IndexedStateT[F, S, S, A]

    Permalink

    StateT[F, S, A] is similar to Kleisli[F, S, A] in that it takes an S argument and produces an A value wrapped in F.

    StateT[F, S, A] is similar to Kleisli[F, S, A] in that it takes an S argument and produces an A value wrapped in F. However, it also produces an S value representing the updated state (which is wrapped in the F context along with the A value.

  51. type Store[S, A] = RepresentableStore[[β$0$](S) ⇒ β$0$, S, A]

    Permalink
  52. final case class Tuple2K[F[_], G[_], A](first: F[A], second: G[A]) extends Product with Serializable

    Permalink

    Tuple2K is a product to two independent functor values.

    Tuple2K is a product to two independent functor values.

    See: The Essence of the Iterator Pattern

  53. sealed abstract class Validated[+E, +A] extends Product with Serializable

    Permalink
  54. type ValidatedNec[+E, +A] = Validated[NonEmptyChain[E], A]

    Permalink
  55. type ValidatedNel[+E, +A] = Validated[NonEmptyList[E], A]

    Permalink
  56. type Writer[L, V] = WriterT[Id, L, V]

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

    Permalink
  58. final class ZipList[A] extends AnyVal

    Permalink
  59. final class ZipStream[A] extends AnyVal

    Permalink
  60. final class ZipVector[A] extends AnyVal

    Permalink

Value Members

  1. object AndThen extends AndThenInstances0 with Serializable

    Permalink
  2. object AppFunc extends AppFuncInstances

    Permalink
  3. object Binested extends BinestedInstances with Serializable

    Permalink
  4. object Chain extends ChainInstances

    Permalink
  5. object Cokleisli extends CokleisliInstances with Serializable

    Permalink
  6. object Const extends ConstInstances with Serializable

    Permalink
  7. object ContT extends Serializable

    Permalink
  8. object EitherK extends EitherKInstances with Serializable

    Permalink
  9. object EitherT extends EitherTInstances with Serializable

    Permalink
  10. object Func extends FuncInstances

    Permalink
  11. val IRWST: IndexedReaderWriterStateT.type

    Permalink
  12. object IdT extends IdTInstances with Serializable

    Permalink
  13. object IndexedReaderWriterStateT extends IRWSTInstances with CommonIRWSTConstructors with Serializable

    Permalink
  14. object IndexedState extends IndexedStateFunctions with Serializable

    Permalink
  15. object IndexedStateT extends IndexedStateTInstances with CommonStateTConstructors0 with Serializable

    Permalink
  16. object Ior extends IorInstances with IorFunctions with IorFunctions2 with Serializable

    Permalink
  17. object IorT extends IorTInstances with Serializable

    Permalink
  18. object Kleisli extends KleisliInstances with KleisliFunctions with KleisliFunctionsBinCompat with KleisliExplicitInstances with Serializable

    Permalink
  19. object Nested extends NestedInstances with Serializable

    Permalink
  20. val NonEmptyChain: NonEmptyChainImpl.type

    Permalink
  21. object NonEmptyList extends NonEmptyListInstances with Serializable

    Permalink
  22. val NonEmptyMap: NonEmptyMapImpl.type

    Permalink
  23. val NonEmptySet: NonEmptySetImpl.type

    Permalink
  24. def NonEmptyStream[A](head: A, tail: A*): NonEmptyStream[A]

    Permalink
  25. def NonEmptyStream[A](head: A, tail: Stream[A] = Stream.empty): NonEmptyStream[A]

    Permalink
  26. object NonEmptyVector extends NonEmptyVectorInstances with Serializable

    Permalink
  27. object OneAnd extends OneAndInstances with Serializable

    Permalink
  28. object Op extends OpInstances with Serializable

    Permalink
  29. object OptionT extends OptionTInstances with Serializable

    Permalink
  30. val RWS: ReaderWriterState.type

    Permalink
  31. val RWST: ReaderWriterStateT.type

    Permalink
  32. object Reader extends Serializable

    Permalink
  33. val ReaderT: Kleisli.type

    Permalink
  34. object ReaderWriterState extends RWSFunctions with Serializable

    Permalink
  35. object ReaderWriterStateT extends RWSTFunctions with Serializable

    Permalink
  36. object RepresentableStore extends Serializable

    Permalink
  37. object State extends StateFunctions with Serializable

    Permalink
  38. object StateT extends StateTFunctions with CommonStateTConstructors0 with Serializable

    Permalink
  39. object Store extends Serializable

    Permalink
  40. object Tuple2K extends Tuple2KInstances with Serializable

    Permalink
  41. object Validated extends ValidatedInstances with ValidatedFunctions with ValidatedFunctionsBinCompat0 with Serializable

    Permalink
  42. object Writer extends Serializable

    Permalink
  43. object WriterT extends WriterTInstances with WriterTFunctions with Serializable

    Permalink
  44. object ZipList

    Permalink
  45. object ZipStream

    Permalink
  46. object ZipVector

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped