Alan & Kim Zimmerman
alan.zimm at gmail.com
Sun Oct 3 22:34:21 UTC 2021
With a pointer from Vlad and some study of the lens tutorial, I made a
proof of concept at .
I am deliberately not using the existing lens library as I envisage this
code ending up in GHC.
On Sun, 3 Oct 2021 at 18:52, Vladislav Zavialov <vladislav at serokell.io>
> Hi Alan,
> Your pair of functions can be packaged up as a single function, so that
> getEpa :: a -> EpaLocation
> setEpa :: a -> EpaLocation -> a
> lensEpa :: forall f. Functor f => (EpaLocation -> f EpaLocation)
> -> (a -> f a)
> And the get/set parts can be recovered by instantiating `f` to either
> Identity or Const.
> The nice thing about lenses is that they compose, so that if you need
> nested access, you could define several lenses, compose them together, and
> then reach deep into a data structure. Then lenses might offer some
> simplification. Otherwise, an ordinary getter/setter pair is just as good.
> - Vlad
> > On 3 Oct 2021, at 20:40, Alan & Kim Zimmerman <alan.zimm at gmail.com>
> > Hi all
> > I am working on a variant of the exact printer which updates the
> annotation locations from the `EpaSpan` version to the `EpaDelta` version,
> as the printing happens
> > data EpaLocation = EpaSpan RealSrcSpan
> > | EpaDelta DeltaPos
> > The function doing the work is this
> > markAnnKw :: (Monad m, Monoid w)
> > => EpAnn a -> (a -> EpaLocation) -> (a -> EpaLocation -> a) ->
> AnnKeywordId -> EP w m (EpAnn a)
> > which gets an annotation, a function to pull a specific location out,
> and one to update it.
> > I do not know much about lenses, but have a feeling that I could
> simplify things by using one.
> > Can anyone give me any pointers?
> > Alan
> > _______________________________________________
> > ghc-devs mailing list
> > ghc-devs at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs