Each provides a
Traversal that can focus into a structure
S to see all its foci
Each can easily be created given a
import arrow.data.* import arrow.optics.* import arrow.optics.typeclasses.* val each: Each<ListKOf<Int>, Int> = Each.fromTraverse(ListK.traverse()) val listTraversal: Traversal<ListKOf<Int>, Int> = each.each() listTraversal.lastOption(listOf(1, 2, 3).k()) // Some(3)
listTraversal.lastOption(ListK.empty()) // None
Each instances for some common datatypes in Arrow. You can look them up by calling
You may create instances of
Each for your own datatypes which you will be able to use as demonstrated in the example above.
See Deriving and creating custom typeclass to provide your own
Each instances for custom datatypes.
The following datatypes in Arrow provide instances that adhere to the