Comments (8)
Lens.satisfy(&(&1))
is what i used
this may be worthy of adding to the library as an idiom
or do you know of a different way to do this that is better/idiomatic?
from lens.
Not quite sure what you mean - could you post an example?
from lens.
Do you mean you want something like:
iex> Lens.to_list(lens, %{a: 1})
[1]
iex> Lens.to_list(lens, %{})
[]
from lens.
yeah, so i had a parent node that is sometimes nil, and i focus on it's children.
so similar to what you posted
from lens.
example
:secondary is sometime nil
people_lens =
Lens.multiple([
Lens.key(:primary),
Lens.key(:secondary)])
|> Lens.satisfy(exists) #existence check
age_lens =
people_lens
|> Lens.both(Lens.key(:children) |> Lens.all)
|> Lens.key(:age)
from lens.
Yeah, I think Lens.satisfy(&(&1))
is fine for this case... Not sure if there should be a separate function for this if such an easy solution exists.
from lens.
I think it may not be obvious.
may need more examples of how to use the library.
from lens.
If you think you have a way to make this obvious in the API, please make a PR, closing for now.
from lens.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lens.