Cats Api Documentation

Version: 2.2.0

cats.protocols

A collection of protocols upon which the cats abstractions are built.

NOTE: Functions of this namespace are not intended to be used directly. It is considered internal api.

Applicative

protocol

The Applicative abstraction.

members

-fapply

(-fapply app af av)

Applies the function(s) inside af’s context to the value(s) inside av’s context while preserving the context.

-pure

(-pure app v)

Takes any context or monadic value app and any value v, and puts the value v in the most minimal context (normally mempty) of same type of app

Bifunctor

protocol

A ‘Functor’ of two arguments.

members

-bimap

(-bimap btor f g bv)

Map over both arguments at the same time.

Context

protocol

A marker protocol for identifying the valid context types.

Contextual

protocol

Abstraction that establishes a concrete type as a member of a context.

A great example is the Maybe monad type Just. It implements this abstraction to establish that Just is part of the Maybe monad.

members

-get-context

(-get-context _)

Get the context associated with the type.

Extract

protocol

A type class to extract the value from a monad context.

members

-extract

(-extract mv)

Extract the value from monad context.

Foldable

protocol

Abstraction of data structures that can be folded to a summary value.

members

-foldl

(-foldl fctx f z xs)

Left-associative fold of a structure.

-foldr

(-foldr fctx f z xs)

Right-associative fold of a structure.

Functor

protocol

A data type that can be mapped over without altering its context.

members

-fmap

(-fmap ftor f fv)

Applies function f to the value(s) inside the context of the functor fv.

Monad

protocol

The Monad abstraction.

members

-mbind

(-mbind m mv f)

-mreturn

(-mreturn m v)

MonadPlus

protocol

A complement abstraction for Monad that supports the notion of addition.

members

-mplus

(-mplus m mv mv')

An associative addition operation.

MonadZero

protocol

A complement abstraction for monad that supports the notion of an identity element.

members

-mzero

(-mzero m)

The identity element for the given monadzero.

Monoid

protocol

A Semigroup which has an identity element with respect to an associative binary operation.

members

-mempty

(-mempty s)

The identity element for the given monoid.

Printable

protocol

An abstraction to make a type printable in a platform independent manner.

members

-repr

(-repr _)

Get the repl ready representation of the object.

Semigroup

protocol

A structure with an associative binary operation.

members

-mappend

(-mappend s sv sv')

An associative addition operation.

Traversable

protocol

Abstraction of data structures that can be traversed from left to right performing an action on every element.

members

-traverse

(-traverse tctx f tv)

Map each element to an Applicative, evaluate the applicatives from left to right and collect the results.