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
Thank you for reminding me this functional concept, I didn’t know there was lens libraries in Elixir, that’s interesting for managing nested structures.
About your request and including more features in general: I have thought about handling Ecto as well, but finally I think it would be better if typed_struct remains a tiny library. Users not using Ecto or a lense library don’t need code related to these features. It would be better if they were in different packages. What I can add in typed_struct however is some plugin system to build upon. This way, if you wanted to define lenses for the keys of a typed struct, you could do something like this:
defmoduleMyStructdouseTypedStruct# This would contain the define_lenses/? function.importLensPlugintypedstructdoplugin:define_lensesfield:name,String.t()field:age,integer()endend
I’ve thought of this API in 5 minutes, it could change but you get the idea. This way, users could define callbacks that would be called during the typed struct definition, accessing to its fields. I will open a separate issue for this plugin feature.
Hi,
Did you consider providing some integration with one or more lens libraries ?
https://github.com/tpoulsen/focus → they already have a "deflens" macro, that defines struct and lenses at the same time
https://github.com/obrok/lens → seems more feature complete
Thanx for your library !
The text was updated successfully, but these errors were encountered: