purescript-contrib / purescript-profunctor-lenses

Pure profunctor lenses
MIT License
144 stars 52 forks source link

Add `prop` variant using VTA #145

Open amesgen opened 1 year ago

amesgen commented 1 year ago

Description of the change Adds a variant of prop using VTA (visible type application) which was added in Purescript 0.15.10. Motivation is mainly to save some characters:

prop @"foo"                 :: forall a b r. Lens { foo :: a | r } { foo :: b | r } a b

vs

prop (Proxy :: Proxy "foo") :: forall a b r. Lens { foo :: a | r } { foo :: b | r } a b
prop (Proxy :: _ "foo")     :: forall a b r. Lens { foo :: a | r } { foo :: b | r } a b

I chose to also name it prop and put it in a new module (as it seems very unlikely that both variants are used in the same project), but also happy to change to other alternatives, like naming it prop' and putting it in Data.Lens.Record, or simply replacing the current prop with the VTA-enabled prop (would be a breaking change).


Checklist:

JordanMartinez commented 11 months ago

Adding VTAs to the ecosystem is something I was planning to do in the 0.16.0 ecosystem update. And before that happens, we need to specify some guidelines for how to do this, so that whatever design we come up with is consistent across the ecosystem rather than ad-hoc designs that differ across libraries.

If you're interested in contributing to this effort, please type up some initial guidelines on Discourse.

bakhtiyarneyman commented 10 months ago

prop is by far the most frequently referenced function in our codebase. This is an opportunity to pick a shorter name for the combinator. How about on?

JordanMartinez commented 10 months ago

Does your codebase entail a library or application. If the latter, there's nothing stopping you from defining your own prelude with its custom imports to suit your naming preferences.

bakhtiyarneyman commented 10 months ago

It's an application, and indeed we do have a P4 for exactly that!