Cats Api Documentation

Version: 1.2.0

cats.labs.lens

->Foci

(->Foci trav a)

Positional factory function for class cats.labs.lens.Foci.

->Focus

(->Focus lens a)

Positional factory function for class cats.labs.lens.Focus.

both

(both one other)

Given two traversals, compose them in parallel. The getter of the resulting traversal will combine results from both traversals and the setter will update the state with both setters.

const-setter

(const-setter s _)

The constant setter, returns the state unaltered.

each

A traversal into each element of a sequence.

ffoci

(ffoci traversal s)

Given a traversal and a state, return the first value focused by the traversal.

filter

(filter applies?)

Given a predicate, return a traversal that focuses the elements that pass the predicate.

foci

(foci traversal s)

Given a traversal and a state, return the values focused by the traversal.

foci-atom

(foci-atom traversal a)

focus

(focus lens s)

Given a lens and a state, return the value focused by the lens.

focus-atom

(focus-atom lens a)

id

Identity lens.

id-setter

(id-setter s f)

The identity setter, applies the function to the state.

in

(in path)(in path default)

Given a path and optionally a default value, return a lens that focuses the given path in an associative data structure.

it

Identity traversal.

key

(key k)

Given a key, returns a lens that focuses on the given key of an associative data structure.

keys

Focus on the keys of an associative data structure.

lens

(lens getter setter)

Given a function for getting the focused value from a state (getter) and a function that takes the state and and update function (setter), constructs a lens.

lens->traversal

(lens->traversal l)

Derive a traversal from a lens.

nothing

Identity traversal under both.

nth

(nth n)

Given a number, returns a lens that focuses on the given index of a collection.

only

(only applies?)

Given a predicate, return a traversal that filters a coll.

over

(over st f s)

Given a setter, a function and a state, apply the function over the value focused by the setter.

passes

(passes applies?)

Given a predicate, return a lens that focuses in an element only if passes the predicate.

The lens is not well-behaved, depens on the outcome of the predicate.

put

(put st v s)

Given a setter, a new value and a state, replace the value focused by the lens with the new one.

select-keys

(select-keys ks)

Return a lens focused on the given keys in an associative data structure.

tail

A lens into the tail of a collection.

traversal

(traversal getter setter)

Given a function for getting the focused values from a state (getter) and a function that takes the state and and update function (setter), constructs a traversal.

units

(units one->other other->one)

Given a function from unit A to unit B and another in the opposite direction, construct a lens that focuses and updates a converted value.

vals

Focus on the values of an associative data structure.