cats.data
Members list
Type members
Classlikes
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)
}
Attributes
- Companion:
- object
- Source:
- AndThen.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- AndThen.scala
- Graph
- Supertypes
- Self type
- AndThen.type
An implementation of Func that's specialized to Applicative.
An implementation of Func that's specialized to Applicative.
Attributes
- Companion:
- object
- Source:
- Func.scala
- Graph
- Supertypes
- Self type
Attributes
- Companion:
- class
- Source:
- Func.scala
- Graph
- Supertypes
- Self type
- AppFunc.type
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:
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"))
Attributes
- Companion:
- object
- Source:
- Binested.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- Binested.scala
- Graph
- Supertypes
- Self type
- Binested.type
Attributes
- Source:
- Binested.scala
- Graph
- Supertypes
- Known subtypes
Attributes
- Source:
- Binested.scala
- Graph
- Supertypes
Attributes
- Source:
- Binested.scala
- Graph
- Supertypes
- Known subtypes
- object Binested.type
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).
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).
Attributes
- Companion:
- object
- Source:
- Chain.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- Chain.scala
- Graph
- Supertypes
- Self type
- Chain.type
Represents a function F[A] => B
.
Represents a function F[A] => B
.
Attributes
- Companion:
- object
- Source:
- Cokleisli.scala
- Graph
- Supertypes
- Self type
Attributes
- Companion:
- class
- Source:
- Cokleisli.scala
- Graph
- Supertypes
- Self type
- Cokleisli.type
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
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
Attributes
- Companion:
- object
- Source:
- Const.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- Const.scala
- Graph
- Supertypes
- Self type
- Const.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- Cont.type
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.
Attributes
- Companion:
- object
- Source:
- ContT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- ContT.scala
- Graph
- Supertypes
- Self type
- ContT.type
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
.
Attributes
- run
The underlying
scala.util.Either
.- Companion:
- object
- Source:
- EitherK.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- EitherK.scala
- Graph
- Supertypes
- Self type
- EitherK.type
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
.
Attributes
- Companion:
- object
- Source:
- EitherT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- EitherT.scala
- Graph
- Supertypes
- Self type
- EitherT.type
Func is a function A => F[B]
.
Func is a function A => F[B]
.
Attributes
- Companion:
- object
- Source:
- Func.scala
- Graph
- Supertypes
- Known subtypes
- Self type
Attributes
- Companion:
- class
- Source:
- Func.scala
- Graph
- Supertypes
- Self type
- Func.type
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]
.
Attributes
- Companion:
- object
- Source:
- IndexedReaderWriterStateT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- IndexedReaderWriterStateT.scala
- Graph
- Supertypes
- Self type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- IndexedState.type
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
.
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.
Attributes
- Companion:
- object
- Source:
- IndexedStateT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- IndexedStateT.scala
- Graph
- Supertypes
- Self type
- IndexedStateT.type
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:
[[Ior.Left Left]][A]
[[Ior.Right Right]][B]
[[Ior.Both Both]][A, B]
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.
Attributes
Attributes
- Companion:
- object
- Source:
- IorT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- IorT.scala
- Graph
- Supertypes
- Self type
- IorT.type
Represents a function A => F[B]
.
Represents a function A => F[B]
.
Attributes
- Companion:
- object
- Source:
- Kleisli.scala
- Graph
- Supertypes
- Self type
Attributes
- Companion:
- class
- Source:
- Kleisli.scala
- Graph
- Supertypes
- Self type
- Kleisli.type
Attributes
- Source:
- Kleisli.scala
- Graph
- Supertypes
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)
Attributes
- Companion:
- object
- Source:
- Nested.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- Nested.scala
- Graph
- Supertypes
- Self type
- Nested.type
Actual implementation for cats.data.NonEmptyChain
Actual implementation for cats.data.NonEmptyChain
Attributes
- Note:
This object is kept public for the sake of binary compatibility only and therefore is subject to changes in future versions of Cats. Do not use directly - use cats.data.NonEmptyChain instead.
- Source:
- NonEmptyChain.scala
- Graph
- Supertypes
- Self type
- NonEmptyChainImpl.type
Attributes
- Source:
- NonEmptyChain.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Source:
- NonEmptyLazyList.scala
- Graph
- Supertypes
- Self type
- NonEmptyLazyList.type
Attributes
- Source:
- NonEmptyLazyList.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
A data type which represents a non empty list of A, with single element (head) and optional structure (tail).
A data type which represents a non empty list of A, with single element (head) and optional structure (tail).
Attributes
- Companion:
- object
- Source:
- NonEmptyList.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- NonEmptyList.scala
- Graph
- Supertypes
- Self type
- NonEmptyList.type
Actual implementation for cats.data.NonEmptyMap
Actual implementation for cats.data.NonEmptyMap
Attributes
- Note:
This object is kept public for the sake of binary compatibility only and therefore is subject to changes in future versions of Cats. Do not use directly - use cats.data.NonEmptyMap instead.
- Source:
- NonEmptyMapImpl.scala
- Graph
- Supertypes
- Self type
- NonEmptyMapImpl.type
Attributes
- Source:
- NonEmptyMapImpl.scala
- Graph
- Supertypes
A data type which represents a Seq
guaranteed to contain at least one element.
Note that the constructor is private
to prevent accidental construction of an empty
NonEmptySeq
. However, due to https://issues.scala-lang.org/browse/SI-6601, on
Scala 2.10, this may be bypassed due to a compiler bug.
A data type which represents a Seq
guaranteed to contain at least one element.
Note that the constructor is private
to prevent accidental construction of an empty
NonEmptySeq
. However, due to https://issues.scala-lang.org/browse/SI-6601, on
Scala 2.10, this may be bypassed due to a compiler bug.
Attributes
- Companion:
- object
- Source:
- NonEmptySeq.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- NonEmptySeq.scala
- Graph
- Supertypes
- Self type
- NonEmptySeq.type
Actual implementation for cats.data.NonEmptySet
Actual implementation for cats.data.NonEmptySet
Attributes
- Note:
This object is kept public for the sake of binary compatibility only and therefore is subject to changes in future versions of Cats. Do not use directly - use cats.data.NonEmptySet instead.
- Source:
- NonEmptySet.scala
- Graph
- Supertypes
- Self type
- NonEmptySetImpl.type
Attributes
- Source:
- NonEmptySet.scala
- Graph
- Supertypes
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.
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.
Attributes
- Companion:
- object
- Source:
- NonEmptyVector.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- NonEmptyVector.scala
- Graph
- Supertypes
- Self type
- NonEmptyVector.type
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:
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]
Attributes
- Companion:
- object
- Source:
- OneAnd.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- OneAnd.scala
- Graph
- Supertypes
- Self type
- OneAnd.type
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.
Attributes
- Companion:
- object
- Source:
- OptionT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- OptionT.scala
- Graph
- Supertypes
- Self type
- OptionT.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- Reader.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- ReaderWriterState.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- ReaderWriterStateT.type
A generalization of StoreT
, where the underlying functor F
has a Representable
instance.
Store
is the dual of State
A generalization of StoreT
, where the underlying functor F
has a Representable
instance.
Store
is the dual of State
Attributes
- Companion:
- object
- Source:
- RepresentableStore.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- RepresentableStore.scala
- Graph
- Supertypes
- Self type
- RepresentableStore.type
Attributes
- Companion:
- object
- Source:
- RepresentableStoreT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- RepresentableStoreT.scala
- Graph
- Supertypes
- Self type
- RepresentableStoreT.type
Attributes
- Source:
- RepresentableStoreT.scala
- Graph
- Supertypes
- Known subtypes
- object RepresentableStoreT.type
Attributes
- Source:
- RepresentableStoreT.scala
- Graph
- Supertypes
- Known subtypes
- object RepresentableStoreT.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- State.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- StateT.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- Store.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- StoreT.type
Tuple2K is a product to two independent functor values.
Tuple2K is a product to two independent functor values.
Attributes
- Companion:
- object
- Source:
- Tuple2K.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- Tuple2K.scala
- Graph
- Supertypes
- Self type
- Tuple2K.type
Attributes
- Companion:
- object
- Source:
- Validated.scala
- Graph
- Supertypes
- Known subtypes
Attributes
- Companion:
- class
- Source:
- Validated.scala
- Graph
- Supertypes
- Self type
- Validated.type
Attributes
- Source:
- package.scala
- Graph
- Supertypes
- Self type
- Writer.type
Attributes
- Companion:
- object
- Source:
- WriterT.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- WriterT.scala
- Graph
- Supertypes
- Self type
- WriterT.type
Attributes
- Companion:
- object
- Source:
- ZipLazyList.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- ZipLazyList.scala
- Graph
- Supertypes
- Self type
- ZipLazyList.type
Attributes
- Companion:
- object
- Source:
- ZipList.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- ZipList.scala
- Graph
- Supertypes
- Self type
- ZipList.type
Attributes
- Companion:
- object
- Source:
- ZipSeq.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- ZipSeq.scala
- Graph
- Supertypes
- Self type
- ZipSeq.type
Attributes
- Companion:
- object
- Source:
- ZipVector.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Source:
- ZipVector.scala
- Graph
- Supertypes
- Self type
- ZipVector.type
Deprecated classlikes
Attributes
- Companion:
- object
- Deprecated
- true
- Source:
- ZipStream.scala
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Attributes
- Companion:
- class
- Deprecated
- true
- Source:
- ZipStream.scala
- Graph
- Supertypes
- Self type
- ZipStream.type
Types
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Represents a stateful computation in a context F[_]
, over state S
, with an
initial environment E
, an accumulated log L
and a result A
.
Represents a stateful computation in a context F[_]
, over state S
, with an
initial environment E
, an accumulated log L
and a result A
.
Attributes
- Source:
- package.scala
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.
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.
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Inherited types
Attributes
- Inherited from:
- ScalaVersionSpecificPackage (hidden)
- Source:
- ScalaVersionSpecificPackage.scala
Deprecated and Inherited types
Attributes
- Deprecated
- true
- Inherited from:
- ScalaVersionSpecificPackage (hidden)
- Source:
- ScalaVersionSpecificPackage.scala
Value members
Deprecated and Inherited methods
Attributes
- Deprecated
- true
- Inherited from:
- ScalaVersionSpecificPackage (hidden)
- Source:
- ScalaVersionSpecificPackage.scala
Attributes
- Deprecated
- true
- Inherited from:
- ScalaVersionSpecificPackage (hidden)
- Source:
- ScalaVersionSpecificPackage.scala
Concrete fields
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala
Attributes
- Source:
- package.scala