-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Records (with optics?) #9
Comments
Since I really like the idea of introducing optics as if it was something super simply and approachable and wanted to check out that new package anyway I'll get on it 💯 |
If that is a road you want to go down, I'd recommend taking a hard look at going the path of generic-lens (https://hackage.haskell.org/package/generic-lens) and generic-lens-labels (http://hackage.haskell.org/package/generic-lens-labels) rather than that of I'm a big fan of |
Either way you want to get your lenses, records with optics up front is--I think--the right way to go. Using optics to modify a deeply-nested field is a way in which Haskell records are genuinely, objectively better than imperative languages. E.g. in imperative code, you can use |
Here's a records demo we wrote a while back:
Lately I'm feeling like the Phrasebook should just immediately introduce optics from the start.
Maybe that's too radical. On the other hand, maybe introducing it now in an extremely simple context is good setup for a later page on doing "deep updates" with composed lenses. I think in a later page we could end up showing how to get a lot of of optics using only
view
,set
,over
, and(%)
without being overwhelming.The text was updated successfully, but these errors were encountered: