<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Continuing my example, you can store manager-to-salary mapping separately, in which case you won't need deep updates. I don't think there is a universal solution, same as there is no universal "best" way to translate an imperative program into a functional language.<br><br><div id="AppleMailSignature">Az iPademről küldve</div><div><br>2018. máj. 15. dátummal, 23:00 időpontban Dennis Raddle <<a href="mailto:dennis.raddle@gmail.com">dennis.raddle@gmail.com</a>> írta:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 15, 2018 at 7:27 AM, Mig Mit <span dir="ltr"><<a href="mailto:migmit@gmail.com" target="_blank">migmit@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Dennis probably means that when in imperative language you'd write<div><br></div><div>employee.department.manager.<wbr>salary += 1000</div><div><br></div><div>in vanilla Haskell it would be like</div><div><br></div><div>newSalary = employee.department.manager.<wbr>salary + 1000</div><div>newManager = employee.department.manager {salary = newSalary}</div><div>newDepartment = employee.department {manager = newManager}</div><div>newEmployee = employee {department = newDepartment}</div><div><br></div><div>Lazyness have nothing to do with it. This is actually where lenses usually come in, although I'd argue that the data should rather be restructured.<div><div class="h5"><br></div></div></div></div></blockquote><div><br></div><div>That's what I mean.</div><div><br></div><div>In what sense can I restructure the data? My current application has lots of "composite" data... conceptually, "things" each of which hold a lot of "other things" each of which hold a lot of "still other things". And sometimes I want to update a single one of those "still other things".</div><div><br></div><div>Lenses seem like a good solution, but if you have a better idea, let me know.</div><div><br></div><div>D<br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div class="h5"><div><br><blockquote type="cite"><div>On 2018. May 15., at 16:01, Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io" target="_blank">vanessa.mchale@iohk.io</a>> wrote:</div><br class="m_-6834846054261548386Apple-interchange-newline"><div>
<div text="#000000" bgcolor="#FFFFFF"><p>>In Haskell, if using immutable data, this would requiring
doing a data update on every level</p><p>I'm not sure what you mean but in either case it doesn't have to
do with immutability. Haskell is lazy, so your updates will only
happen if the field is later accessed. The other fields in the
record will only be updated if they A) change and B) are later
accessed. If you just updated one field of a record the other
fields will still have pointers to the old data.<br>
<br>
Otherwise, I agree with Matt's answer. Lenses handle this problem
nicely :)<br>
</p>
<div class="m_-6834846054261548386moz-cite-prefix">On 05/14/2018 07:41 PM, Dennis Raddle
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>In my current application, I'm really missing the ability
from OO to do things like</div>
<div><br>
</div>
<div>someData.field1.field2 = "foo"</div>
<div><br>
</div>
<div>What's do I mean?<br>
</div>
<div><br>
</div>
<div>- field selectors are scoped so that names don't clash with
each other or global names</div>
<div><br>
</div>
<div>- this way of selecting data can be used both for reading
it, and for updating specific fields of some data deep in a
data hierarchy (In Haskell, if using immutable data, this
would requiring doing a data update on every level). </div>
<div><br>
</div>
<div>Any attempt to do this in Haskell, for me anyway, results
in an explosion of names and a lot of boilerplate code and a
resulting heavy syntax.</div>
<div><br>
</div>
<div>Is there a way of obtaining OO-like concise syntax, perhaps
with Template Haskell?</div>
<div><br>
</div>
<div>Dennis</div>
<div><br>
</div>
</div>
<br>
<fieldset class="m_-6834846054261548386mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="m_-6834846054261548386moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</blockquote>
<br>
<div class="m_-6834846054261548386moz-signature">-- <br>
<br>
<br>
<br>
<b style="font-family:Helvetica,Arial;font-size:116%">Vanessa
McHale</b><br>
<span style="font-family:Helvetica,Arial;font-size:100%"><span style="color:#f00">Functional Compiler Engineer |</span>
Chicago, IL</span>
<br>
<br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Website:
<a href="http://iohk.io/" style="color:#f00" target="_blank">www.iohk.io</a></span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Twitter:
@vamchale</span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">PGP
Key ID: 4209B7B5</span><br>
<br>
<a href="http://iohk.io/" target="_blank"><img src="https://static.iohk.io/logo/logo-email.png" alt="Input
Output" width="200" height="46"></a>
<br>
<br>
<a href="https://twitter.com/InputOutputHK" target="_blank"><img src="https://static.iohk.io/images/ic-tw.png" alt="Twitter" width="18" height="16"></a>
<a href="https://github.com/input-output-hk" target="_blank"><img src="https://static.iohk.io/images/ic-gh.png" alt="Github" width="21" height="16"></a>
<a href="https://www.linkedin.com/company/input-output-global" target="_blank"><img src="https://static.iohk.io/images/ic-li.png" alt="LinkedIn" width="19" height="16"></a>
<br>
</div>
</div>
______________________________<wbr>_________________<br>Haskell-Cafe mailing list<br>To (un)subscribe, modify options or view archives go to:<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br></div></div></div></div><br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div></div>
</div></blockquote></body></html>