Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wiki improvement] - Small improvement in [WithLens] example #1077

Open
kgkoutis opened this issue Jun 29, 2022 · 0 comments
Open

[Wiki improvement] - Small improvement in [WithLens] example #1077

kgkoutis opened this issue Jun 29, 2022 · 0 comments

Comments

@kgkoutis
Copy link

The code listings found here and here are generally speaking ok, but if you copy paste them directly to your project you will probably get squiggly lines. In particular this method

// Local function for composing a new lens from 3 other lenses
Lens<Person, ApptState> setState(int id) =>
       lens(Person.appts, Map<int, Appt>.item(id), Appt.state);

Map might refer to Prelude.Map (a method) and LanguageExt.Map (a type). Chances are higher that you will miss 5-10 minutes fiddling with your code why it doesn't work until you decide to decompile it and since it involves code generation it becomes more obscure to the untrained eye of this library. Therefore the improvement I propose is to include the namespace like so:

// Local function for composing a new lens from 3 other lenses
Lens<Person, ApptState> setState(int id) =>
       lens(Person.appts, LanguageExt.Map<int, Appt>.item(id), Appt.state);

Aside from this fix, I do propose to include another gist for the source generated code also for this example (like Click here to see the generated code) and also for [WithLens] section - that basically introduces the With method on A. What might be evident to some, might seem magic to first time visitors that want to take a grasp on what's going on in the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant