<div dir="ltr"><div>Edward, I think the point that Simon was making was that sweetened expressions like `#bar` could directly instantiate lenses if only Lens was a distinct type, instead of an alias to a function. I.e., it would be `#bar . #baz`.</div><div><br></div><div>Introducing such a change would, of course, exclude the possibility of making "lens"-compatible libraries without depending on "lens", like I did with "record". However the most basic functionality of "lens" could be extracted into a separate library with a minimum of transitive dependencies, then the reasons for not depending on it would simply dissolve.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-26 23:22 GMT+03:00 Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Personally, I don't like the sigil mangled version at all. <div><br></div><div>If it is then further encumbered by a combinator it is now several symbols longer at every single use site than other alternatives put forth in this thread. =(<div><br></div><div>xx #bar . xx #baz</div><div><br></div><div>or</div><div><br></div><div>xx @bar . xx @baz</div><div><br></div><div>compares badly enough against</div><div><br></div><div>bar.baz</div><div><br></div><div>for some as yet unnamed combinator xx and is a big enough tax for all users to unavoidably pay that I fear it would greatly hinder adoption. </div><div><br></div><div><div>The former also has the disadvantage of stealing an operator that is already in wide use.<br></div></div><div><br></div><div>Even assuming the fixity issues can be worked out for some other set of operators to glue these tother we're still looking at</div><div><br></div><div>x^!? #bar!? #baz</div><div><br></div><div>vs.</div><div><br></div><div>x^.bar.baz</div><div><br></div><div>with another set of arcane rules to switch back and forth out of this to deal with the lenses/traversals/prisms/etc that many folks have in their code today. </div><div><br></div><div>It is something like 3 extra sets of symbols to memorize plus a tax of 3 characters per lens use site. </div><div><br></div><div>I know that I for one would hesitate to throw over my template haskell generated lenses for something that was noisier at every use site. For all that lenses are complex internally, they are a lot less arbitrary than that.</div><div><br></div><div>The import Field trick is magic, yes, but it has the benefit of being the first approach I've seen where the resulting syntax can be as light as what the user can generate by hand today.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Edward</div></font></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 26, 2015 at 8:50 AM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>|  "wired" into record selectors, which can't be undone later. I think we<br>
|  can fix some of that by desugaring record definitions to:<br>
|<br>
|  data T = MkT {x :: Int}<br>
|<br>
|  instance FieldSelector "T" T Int where<br>
|       fieldSelector (MkT x) = x<br>
|<br>
|  Then someone can, in a library, define:<br>
|<br>
|  instance FieldSelector x r a => IV x (r -> a) where<br>
|       iv = fieldSelector<br>
|<br>
|  Now that records don't mention IV, we are free to provide lots of<br>
|  different instances, each capturing some properties of each field,<br>
|  without committing to any one style of lens at this point. Therefore,<br>
|  we could have record desugaring also produce:<br>
|<br>
|  instance FieldSetter "T" T Int where<br>
|      fieldSet v (T _) = T v<br>
|<br>
|  And also:<br>
|<br>
|  instance FieldSTAB "T" T Int where<br>
|      fieldSTAB = ... the stab lens ...<br>
<br>
</span>OK, I buy this.<br>
<br>
We generate FieldSelector instances where possible, and FieldSetter instances where possible (fewer cases).<br>
<br>
Fine.<br>
<br>
<br>
<br>
Cutting to the chase, if we are beginning to converge, could someone (Adam, Neil?) modify the Redesign page <a href="https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Redesign" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Redesign</a> to focus on plan B only; and add this FieldGetter/Setter stuff?<br>
<br>
It's confusing when we have too many things in play.  I'm sick at the moment, so I'm going home to bed -- hence handing off in a hopeful way to you two.<br>
<br>
I have added Edwards "import Field(x)" suggestion under syntax, although I don't really like it.<br>
<br>
One last thing: Edward, could you live with lenses coming from #x being of a newtype (Lens a b), or stab variant, rather than actually being a higher rank function etc?  Of course lens composition would no longer be function composition, but that might not be so terrible; ".." perhaps.  It would make error messages vastly more perspicuous. And, much as I love lenses, I think it's a mistake not to abstraction; it dramatically limits your future wiggle room.<br>
<br>
<br>
<br>
I really think we are finally converging.<br>
<div><div><br>
Simon<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
<br></blockquote></div><br></div>