GithubHelp home page GithubHelp logo

Comments (6)

arximboldi avatar arximboldi commented on August 23, 2024 1

Yes, all those lenses and cursors transformations are indeed useful and may be added soon. Thanks! 👍

from lager.

arximboldi avatar arximboldi commented on August 23, 2024 1

You did this, hero! @Siapran

from lager.

Siapran avatar Siapran commented on August 23, 2024

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.

Siapran avatar Siapran commented on August 23, 2024

got an answer on licensing. I'll submit a PR for review soon.

from lager.

arximboldi avatar arximboldi commented on August 23, 2024

Awesome! Those tests are looking good, I like that approach. Looking forward to look at that code 🙂

from lager.

Siapran avatar Siapran commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.