Skip to main content

Tofu optics

Installation

"tf.tofu" %% "tofu" % tofu-version
or as standalone dependencies:
"tf.tofu" %% "tofu-optics-core" % tofu-version
"tf.tofu" %% "tofu-optics-macro" % tofu-version
"tf.tofu" %% "tofu-optics-interop" % tofu-version

Functionality

Tofu contains its own optics library with some notable features:

  • subtyping: You don't need to convert more powerful optic to weaker one
  • unified composition operator

Hierarchy

Docusaurus themed imageDocusaurus themed image

Intuition

If you ever used lens optics' names will be quite familiar to you, but for a Monocle user Tofu's naming may be confusing. The following table may clear things up:

Monocletofu
IsoEquivalent
PrismSubset
LensContains
OptionalProperty
TraversalItems
GetterExtract
FoldFolded
SetterUpdate