[Haskell-cafe] profunctorial vs vanlaarhoven lenses

Paolino paolo.veronelli at gmail.com
Wed May 2 17:09:42 UTC 2018


I'm not using any lens libraries, I'm writing both encodings from scratch
based on standard libs, as a learning path.
I see anyway that Traversing class is declaring exactly the Twan ->
Profunctor promotion (given the Applicative on f)  which looks a lot  like
a white flag on the "write traversal as profunctor" research.
Actually I was induced from purescript to think that the profunctorial
encoding was completely alternative to the twan, but I had no evidence of
the fact, so I should better dig into purescript library.

.p

2018-05-02 18:43 GMT+02:00 Tom Ellis <
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk>:

> I'm not sure what you mean.  If you want to write a profunctor traversal
> then `wander lq5Twan` seems fine.  If you want to understand why it's hard
> to directly write profunctor traversals then I'm afraid I'm as puzzled as
> you.
>
> On Wed, May 02, 2018 at 06:29:09PM +0200, Paolino wrote:
> > Well, I can accept it as an evidence of why  not to use the profunctor
> > encoding for multi target lens (if that's the name).
> > But I guess we are already in philosophy (so I'm more puzzled than
> before)
> > and I hope you can elaborate more.
> >
> > .p
> >
> >
> > 2018-05-02 18:10 GMT+02:00 Tom Ellis <
> > tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk>:
> >
> > > On Wed, May 02, 2018 at 03:07:05PM +0200, Paolino wrote:
> > > > I'm trying to write a lens for a datatype which seems easy in the
> Twan
> > > van
> > > > Laarhoven encoding but I cannot find it as easy in the profunctorial
> one
> > > >
> > > > data Q5 a b = Q51 a (Identity b) | Q52 [b]
> > > >
> > > > lq5Twan :: Applicative f => (b -> f b') -> Q5 a b -> f (Q5 a b')
> > > > lq5Twan f (Q51 a bs) = Q51 a <$> traverse f bs
> > > > lq5Twan f (Q52 bs) = Q52 <$> traverse f bs
> > > [...]
> > > > lq5Profunctor :: forall p a b b' . Traversing p => p b b' -> p (Q5 a
> > > > b) (Q5 a b')
> > > [...]
> > > > Which simpler ways to write the lq5Profunctor we have ?
> > >
> > > Is `wander lq5Twan` good enough, or is your question more
> philosophical?
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180502/81991efa/attachment.html>


More information about the Haskell-Cafe mailing list