Hi Alan, hi Vlad,
Yes, one thing that is nice about van Laarhoven lenses is that you don't
actually need to depend on anything if all you want is export lenses in
your API.
We have also discussed using a small lens library in the past, in
https://gitlab.haskell.org/ghc/ghc/-/issues/18693.
The
With a pointer from Vlad and some study of the lens tutorial, I made a
proof of concept at [1].
I am deliberately not using the existing lens library as I envisage this
code ending up in GHC.
Alan
[1]
Hi Alan,
Your pair of functions can be packaged up as a single function, so that
getEpa :: a -> EpaLocation
setEpa :: a -> EpaLocation -> a
becomes
lensEpa :: forall f. Functor f => (EpaLocation -> f EpaLocation) -> (a
-> f a)
And the get/set parts can be recovered