Comments (6)
Or, does the argument order of lens-set*
and lens-transform*
make more sense? (target first, then lens, then new-value/transformer-function)
It breaks the convention of having the lens as the first argument, but allows the lens and the new-value/transformer-function to be next to each other, and is more consistent with hash-set
, hash-update
, and other similar functions.
from lens.
I'm not sure how to fold plurality into argument conventions, because there's several plural cases:
- Multiple lenses, one target, one view (
lens-view*
) - Multiple lenses, one target, multiple views (
lens-transform*
,lens-set*
) - One lens, multiple targets, one view (possibly something like
lens-set-all
,lens-transform-all
) - One lens, multiple targets, multiple views (possibly something like
lens-set-each
,lens-transform-each
) - Multiple lenses, multiple targets, one view (possibly something like
lens-set-all
for multiple lenses)
And probably more I haven't thought of. The singular lens-view
couldn't be both consistent with a function that takes multiple lenses and a function that takes multiple views if variable-arity functions are desired and the rest arguments are uniform.
from lens.
Well, right now, the argument orders for the single-lens cases of lens-view*
, lens-set*
and lens-transform*
are consistent with each other and consistent with functions like hash-ref
, hash-set
, and hash-update
.
If you thought it would make more sense, you could change all of them to follow that convention, but that breaks the convention of having the lens as the first argument, and also turns it into a postfix-ish feel.
I'm not sure what you mean by lens-view
being consistent with a function that takes multiple views though?
from lens.
I meant lens-set
, my apologies.
from lens.
Maybe worth noting: For the plural of lens-set
, I debated between two possibilities:
(lens-set* target lens ... new-val)
, equivalent to(lens-set (lens-thrush lens ...) target new-val)
(lens-set* target lens new-val ... ...)
, equivalent to(for/fold ([target target]) ([lens/val (in-slice 2 ....)]) (lens-set lens target val))
, filling in the gaps.
I chose the second one because I thought it would be more useful, especially since it's easy to throw a lens-thrush
in there for the first one, and also because the second would be consistent with hash-set*
.
from lens.
Let's move general discussion of argument order to #73
from lens.
Related Issues (20)
- struct->vector isomorphism HOT 5
- lens-zoom examples shouldn't use isomoprhism lenses
- Add digit->char isomorphism
- There should be a test for the cond-lens error case.
- There should be a test for the string-split-lens case where the input violates the lens laws HOT 2
- struct->struct lens? HOT 1
- Rethink unstable collection? HOT 2
- Test `lens-compose` / `compose` relationship HOT 1
- using append* n times vs. flattening a nested list of a given depth HOT 9
- Matrix lenses? HOT 2
- Disarm and re-arm syntax objects within srcloc-lens setters HOT 1
- Modulo lens HOT 3
- Struct inheritence and lenses HOT 32
- How should we name lenses for improper syntax lists? HOT 6
- separate tests into `lens-test` repository HOT 13
- Add prisms or other functionality that tests a lens's applicability HOT 4
- lens-join/* functions produce non-lenses when views overlap HOT 2
- Docs: Is the "last set wins" law right (strong enough)? HOT 3
- Waffle.io has closed HOT 1
- Add seemingly missing (list-filtered-lens) function. HOT 5
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.