Comments (6)
Yes, all those lenses and cursors transformations are indeed useful and may be added soon. Thanks! 👍
from lager.
You did this, hero! @Siapran
from lager.
I need to sort out licensing with my managers but I have a working solution for handling unfocused lenses using optionals: sample unit tests
from lager.
got an answer on licensing. I'll submit a PR for review soon.
from lager.
Awesome! Those tests are looking good, I like that approach. Looking forward to look at that code 🙂
from lager.
I'm trying to make a smart lens for automatically lifting anything that doesn't handle optionals, but I'm having trouble detecting this properly:
struct functor_wrapper_t {
template <typename T>
const_functor<T> operator()(T&& t) const noexcept;
};
template <typename Lens, typename T>
using viewed_t = decltype(
std::declval<Lens>()(functor_wrapper_t{})(std::declval<T>()).value);
template <typename T>
struct smart_lens<std::optional<T>>
{
template <typename U>
static auto make(U &&u) {
// don't lift lenses that can already handle optionals
if constexpr (zug::meta::is_detected<viewed_t, U, std::optional<T>>::value) {
return std::forward<U>(u);
} else {
return ::lager::lens::optlift(smart_lens<T>::make(std::forward<U>(u)));
}
}
};
TEST_CASE("zooming, unfocused")
{
state<std::vector<person>> st{{person{{5, 4}, "juanpe"}}};
auto p = st[0];
auto n1 = p[&person::name];
// auto n2 = p[lens::attr(&person::name)]; // detected as able to handle optional
auto n3 = p[lens::fallback(person{{1, 1}, "NULL"})];
auto n4 = p[lens::optlift(lens::attr(&person::name))];
}
I might need some help to finish implementing this...
from lager.
Related Issues (20)
- Make at lens work for Immer table HOT 2
- Add `post` method to `event_loop_interface`
- Use of destructed object in lager::lenses::getset HOT 6
- Crashes on access to uninitialized reader/writer HOT 1
- Depth first node traversal can cause transform node having merge node as input to be re-evaluated several times with transient values HOT 13
- Compiling with debugger fails with type conversion issues
- Compiling with time travel debugger fails with type conversion issues on Windows HOT 2
- lager::with() and lager::reader<tuple<...>> behave in a non-symmetrical way HOT 8
- Lager library has no official releases HOT 6
- Is resources/gui/gui.scss a mistaken name for resources/gui/gui.css in CMakeLists, or is the resources/gui/gui.css file wrongly named as resources/gui/gui.scss? HOT 1
- (Qt example) using count as model has implications when you need scrolling HOT 1
- Reference link broken HOT 1
- macOS M1 installation issues HOT 3
- Allow forward declaration of type T in reader<T> class member HOT 5
- Abstract dependencies with effects HOT 5
- How to set up on Windows + Unreal Engine HOT 4
- Reader.map(PointerToMemberFunction) does not work on MinGW
- sinusoid.es not resolving / timing out HOT 5
- Exceptions are unexpectedly disabled
- Basic Example doesn't compile on MSVC '17 HOT 3
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 lager.