To flatten lens composition, you can prespecify the data the lens with be applied to by constructing an objectoscope. These can be integrated easily with normal data pipelines.

oscope(d, l = id_l)

Arguments

d

The data for interest

l

The lens to bind the data to. Defaults to the identity lens

Examples

list(a = 5, b = 1:3, c = 8) %>% oscope() %.% index_l("b") %.% index_l(1) %>% set(10)
#> $a #> [1] 5 #> #> $b #> [1] 10 2 3 #> #> $c #> [1] 8 #>