You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we would make an http request to load that model once for each attribute but we would like to load that model only once. To do that we need to convert our paths into a tree structure something like this:
Once we have taken our paths and merged their roots to form a tree, we would like to compose the lenses so we get a new lens that converts n lenses to n values. On the view side we would see something like this:
Lenses.alongside(Lenses.get_predicate_with_name(:paragraph,'.../paragraph'),Lenses.get_predicate_with_name(:footer,'.../footer'))# where get_predicate_with_name returns something like this: [:paragraph, 'some paragraph']# alongside should give a lens that has a view that looks like this:[[:paragraph,'some paragraph'],[:footer,'some footer']]
bmaddy
changed the title
Get Lenses.zip working so we don't traverse the depth of the tree of paths for every attribute
Get Lenses.alongside working so we don't traverse the depth of the tree of paths for every attribute
Apr 15, 2014
Depends on #2.
Say we have some attribute paths that look like this:
Currently, we would make an http request to load that model once for each attribute but we would like to load that model only once. To do that we need to convert our paths into a tree structure something like this:
To do this we'll need to implement
==
in our lens classes. Something like this:Once we have taken our paths and merged their roots to form a tree, we would like to compose the lenses so we get a new lens that converts n lenses to n values. On the view side we would see something like this:
See the relevant stackoverflow question here: https://stackoverflow.com/questions/22865170/what-kind-of-lens-combinator-is-this
The type signature we want can be found here: http://hackage.haskell.org/package/lens-4.1.2/docs/Control-Lens-Lens.html#v%3aalongside
Here's a similar lens (that provides the values without the attribute names) in coffescript:
https://github.com/flazz/lens.js/blob/master/src/lens.coffee#L35-45
There's example usage at the bottom of the readme.
The text was updated successfully, but these errors were encountered: