concrete-optics.prism.structures

Prism constructors and examples.

cons-prism

A prism of vectors which encodes the nonempty pattern. If a vector is nonempty, the the review decomposes it as a map {:head <head> :tail <tail>}.

mk-prism

(mk-prism match review)

Constructs a prism from a pattern matching function and a review. It is the programmers responsibilty to guarantee that a value not matching the pattern is not fed into review

mk-simple-prism

(mk-simple-prism preview review)

Constructs a prism from a preview-review pair.

no-match-alternative?

(no-match-alternative? x)

Checks if a value is equal to a map with :no-match-alternative as it is unique key. Such maps are used when the pattern encoded by a prism is not does not match the given value but an alternative can be supplied.

no-match?

(no-match? x)

Checks if a value is equal to :no-match, a value used in prisms when the pattern encoded by the prism does not match the given value.

predicate-prism

(predicate-prism predicate & [name])

Turns a predicate into prism. In the resulting prism, if the input given to the review does not satisfy the predicate then an exception is thrown. The optional name parameter is used in the exception message.