<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Purely-Functional Incremental Mutation</title>
	<atom:link href="http://blog.lab49.com/archives/2984/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lab49.com/archives/2984</link>
	<description>Technology and industry insights from Lab49.</description>
	<lastBuildDate>Sat, 24 Sep 2011 08:33:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Differentiating Types in Haskell &#187; Lab49 Blog</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113178</link>
		<dc:creator>Differentiating Types in Haskell &#187; Lab49 Blog</dc:creator>
		<pubDate>Mon, 27 Apr 2009 03:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113178</guid>
		<description>[...] type of one-hole contexts.&#160; This &#8220;leap of logic&#8221; gives us a firm foundation for purely-functional incremental mutation, and (more generally) proof that there are interesting things happening at the level of [...]</description>
		<content:encoded><![CDATA[<p>[...] type of one-hole contexts.&nbsp; This &#8220;leap of logic&#8221; gives us a firm foundation for purely-functional incremental mutation, and (more generally) proof that there are interesting things happening at the level of [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Algebra of Data, and the Calculus of Mutation &#187; Lab49 Blog</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113142</link>
		<dc:creator>The Algebra of Data, and the Calculus of Mutation &#187; Lab49 Blog</dc:creator>
		<pubDate>Sun, 19 Apr 2009 04:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113142</guid>
		<description>[...] have previously discussed ways to recover mutation-like functions, inspired by the most famous data structure of its kind: [...]</description>
		<content:encoded><![CDATA[<p>[...] have previously discussed ways to recover mutation-like functions, inspired by the most famous data structure of its kind: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalani Thielen</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113130</link>
		<dc:creator>Kalani Thielen</dc:creator>
		<pubDate>Sun, 12 Apr 2009 19:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113130</guid>
		<description>Dimitre,

Thank you for the comment.  My understanding of finger trees is that they&#039;re sort of a general framework for defining many different types of data structures (e.g.: balanced search trees, covering as special cases most of the structures in the &quot;Purely Functional Data Structures&quot; book).  So in that sense, they provide efficient functions for searching a container, and they may provide functions for mapping a function over a container, but I don&#039;t think they&#039;re especially useful for incrementally walking a data structure.

For folks not familiar with finger trees, I like this page (the link to the original paper on finger trees is there as well):

http://apfelmus.nfshost.com/monoid-fingertree.html

Since finger trees are just another algebraic data type, you could take their derivative to put them in Iterable.  Although, as you and Matt have suggested, arbitrary updates are a little problematic and might be handled better with either finer-grain control (e.g.: MutableIterable, MutableIterator) or with sufficiently intelligent implementations of Iterable (so that arbitrary updates don&#039;t invalidate set/finger-tree invariants).</description>
		<content:encoded><![CDATA[<p>Dimitre,</p>
<p>Thank you for the comment.  My understanding of finger trees is that they&#8217;re sort of a general framework for defining many different types of data structures (e.g.: balanced search trees, covering as special cases most of the structures in the &#8220;Purely Functional Data Structures&#8221; book).  So in that sense, they provide efficient functions for searching a container, and they may provide functions for mapping a function over a container, but I don&#8217;t think they&#8217;re especially useful for incrementally walking a data structure.</p>
<p>For folks not familiar with finger trees, I like this page (the link to the original paper on finger trees is there as well):</p>
<p><a href="http://apfelmus.nfshost.com/monoid-fingertree.html" rel="nofollow">http://apfelmus.nfshost.com/monoid-fingertree.html</a></p>
<p>Since finger trees are just another algebraic data type, you could take their derivative to put them in Iterable.  Although, as you and Matt have suggested, arbitrary updates are a little problematic and might be handled better with either finer-grain control (e.g.: MutableIterable, MutableIterator) or with sufficiently intelligent implementations of Iterable (so that arbitrary updates don&#8217;t invalidate set/finger-tree invariants).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113129</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 12 Apr 2009 16:09:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113129</guid>
		<description>This is a cool way to perform an *update* of any item in a iterable structure.</description>
		<content:encoded><![CDATA[<p>This is a cool way to perform an *update* of any item in a iterable structure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113128</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 12 Apr 2009 16:08:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113128</guid>
		<description>This is a cool way to perform an of any item in a iterable structure.

However, your post does not touch at all the topic of *insertion* of a new item into the structure.

I have found out that the Finger Tree data structure solves all these problems.</description>
		<content:encoded><![CDATA[<p>This is a cool way to perform an of any item in a iterable structure.</p>
<p>However, your post does not touch at all the topic of *insertion* of a new item into the structure.</p>
<p>I have found out that the Finger Tree data structure solves all these problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-04-07 &#124; Data Entry</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113127</link>
		<dc:creator>links for 2009-04-07 &#124; Data Entry</dc:creator>
		<pubDate>Sun, 12 Apr 2009 04:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113127</guid>
		<description>[...] Purely-Functional Incremental Mutation » Lab49 Blog (tags: haskell fp data-structure) [...]</description>
		<content:encoded><![CDATA[<p>[...] Purely-Functional Incremental Mutation » Lab49 Blog (tags: haskell fp data-structure) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalani Thielen</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113124</link>
		<dc:creator>Kalani Thielen</dc:creator>
		<pubDate>Fri, 10 Apr 2009 02:14:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113124</guid>
		<description>Matt,

Oops, you&#039;re right about the redundant descend functions.  I&#039;m not sure how those got in there, but I&#039;ve taken them out. :)

I&#039;m not sure that I completely follow your distinction with the &quot;OO iterator&quot;.  Are you saying that the OO iterator doesn&#039;t support updating?  I can see how updating an arbitrary element in a set would cause problems (although that could be accounted for in the set iterator definition -- similarly to how it&#039;s already accounted for when you insert a redundant element into a set).  However (that issue aside), if you represent a set as a list or as a binary tree, these iterators should work.

You&#039;re right; I should have posted this in Literate Haskell.  Thank you for the suggestion.</description>
		<content:encoded><![CDATA[<p>Matt,</p>
<p>Oops, you&#8217;re right about the redundant descend functions.  I&#8217;m not sure how those got in there, but I&#8217;ve taken them out. <img src='http://blog.lab49.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;m not sure that I completely follow your distinction with the &#8220;OO iterator&#8221;.  Are you saying that the OO iterator doesn&#8217;t support updating?  I can see how updating an arbitrary element in a set would cause problems (although that could be accounted for in the set iterator definition &#8212; similarly to how it&#8217;s already accounted for when you insert a redundant element into a set).  However (that issue aside), if you represent a set as a list or as a binary tree, these iterators should work.</p>
<p>You&#8217;re right; I should have posted this in Literate Haskell.  Thank you for the suggestion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113121</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 09 Apr 2009 20:23:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113121</guid>
		<description>Cool stuff. There&#039;s perhaps a slight difference of emphasis between your Iterator typeclass and the classic Iterator design pattern from OO. The OO Iterator is focused on walking over the actual elements of a data structure, whereas yours is more a sequence of alterable locations of a data structure. For example, it&#039;s not clear what it&#039;d mean to define your Iterator over a Set collection, for example.

P.S. Is it possible to shorten the second definition of forward to: 

   forward  c@(t, (Left  t’):p) = forward (up c)

 (likewise backward), or have I missed something?

P.P.S. It&#039;s be awesome if you could post in Literate Haskell so it&#039;s easier to copy and paste the source to play around with this stuff.</description>
		<content:encoded><![CDATA[<p>Cool stuff. There&#8217;s perhaps a slight difference of emphasis between your Iterator typeclass and the classic Iterator design pattern from OO. The OO Iterator is focused on walking over the actual elements of a data structure, whereas yours is more a sequence of alterable locations of a data structure. For example, it&#8217;s not clear what it&#8217;d mean to define your Iterator over a Set collection, for example.</p>
<p>P.S. Is it possible to shorten the second definition of forward to: </p>
<p>   forward  c@(t, (Left  t’):p) = forward (up c)</p>
<p> (likewise backward), or have I missed something?</p>
<p>P.P.S. It&#8217;s be awesome if you could post in Literate Haskell so it&#8217;s easier to copy and paste the source to play around with this stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: crooney</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113119</link>
		<dc:creator>crooney</dc:creator>
		<pubDate>Thu, 09 Apr 2009 08:07:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113119</guid>
		<description>Thanks for the cogent and easy to follow explanation.  My eyes kind of glazed over at the recent thread on haskell-cafe, but this made it seem simple.</description>
		<content:encoded><![CDATA[<p>Thanks for the cogent and easy to follow explanation.  My eyes kind of glazed over at the recent thread on haskell-cafe, but this made it seem simple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-04-07 &#171; Blarney Fellow</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113114</link>
		<dc:creator>links for 2009-04-07 &#171; Blarney Fellow</dc:creator>
		<pubDate>Wed, 08 Apr 2009 00:12:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113114</guid>
		<description>[...] Purely-Functional Incremental Mutation » Lab49 Blog (tags: haskell fp data-structure) [...]</description>
		<content:encoded><![CDATA[<p>[...] Purely-Functional Incremental Mutation » Lab49 Blog (tags: haskell fp data-structure) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalani Thielen</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113113</link>
		<dc:creator>Kalani Thielen</dc:creator>
		<pubDate>Tue, 07 Apr 2009 17:18:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113113</guid>
		<description>Damien,

I&#039;ll assume you&#039;re not joking (please ignore the rest of my response if you were joking). :)

You&#039;re comparing apples to oranges.  It&#039;s actually quite easy to *use* these iterator types (in fact, that&#039;s the point of putting them in these convenient type-classes).  In the same way, it&#039;s easy to *use* array-indexing/mutation in C.  However, a fair comparison is between this category of type-classes and the compiler-machinery in C that makes &quot;a[i].x+=5&quot; possible.

When *using* these iterators, you could write something like the following to update the 4th value to &quot;foo&quot;:

update (iter_n (open A) 3) &quot;foo&quot;

Even that is a bit long, but it&#039;s pretty much the same as what you&#039;d write in C++ to do the equivalent thing to a linked list:

*(iter_n(A.begin(), 3)) = &quot;foo&quot;

Plus, the update in the Haskell version is purely-functional -- so you can revert to the previous state if necessary or do something with both states, etc.

You might make an argument that the Haskell version is difficult, because you have to figure out how to iterate over some new data structure that you come up with.  However, there&#039;s a straightforward procedure to find that type (it&#039;s just the derivative -- and the compiler itself could do this for you in theory; a future GHC probably will).  OTOH, if you provide iterators for your own data structures in Java/C++, you have to write this kind of code anyway.

Finally, I think I&#039;m a living contradiction to your argument that you have to be in the &quot;brainiest 1% of the planet&quot; or have a PhD to understand this.</description>
		<content:encoded><![CDATA[<p>Damien,</p>
<p>I&#8217;ll assume you&#8217;re not joking (please ignore the rest of my response if you were joking). <img src='http://blog.lab49.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You&#8217;re comparing apples to oranges.  It&#8217;s actually quite easy to *use* these iterator types (in fact, that&#8217;s the point of putting them in these convenient type-classes).  In the same way, it&#8217;s easy to *use* array-indexing/mutation in C.  However, a fair comparison is between this category of type-classes and the compiler-machinery in C that makes &#8220;a[i].x+=5&#8243; possible.</p>
<p>When *using* these iterators, you could write something like the following to update the 4th value to &#8220;foo&#8221;:</p>
<p>update (iter_n (open A) 3) &#8220;foo&#8221;</p>
<p>Even that is a bit long, but it&#8217;s pretty much the same as what you&#8217;d write in C++ to do the equivalent thing to a linked list:</p>
<p>*(iter_n(A.begin(), 3)) = &#8220;foo&#8221;</p>
<p>Plus, the update in the Haskell version is purely-functional &#8212; so you can revert to the previous state if necessary or do something with both states, etc.</p>
<p>You might make an argument that the Haskell version is difficult, because you have to figure out how to iterate over some new data structure that you come up with.  However, there&#8217;s a straightforward procedure to find that type (it&#8217;s just the derivative &#8212; and the compiler itself could do this for you in theory; a future GHC probably will).  OTOH, if you provide iterators for your own data structures in Java/C++, you have to write this kind of code anyway.</p>
<p>Finally, I think I&#8217;m a living contradiction to your argument that you have to be in the &#8220;brainiest 1% of the planet&#8221; or have a PhD to understand this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: damien</title>
		<link>http://blog.lab49.com/archives/2984/comment-page-1#comment-113110</link>
		<dc:creator>damien</dc:creator>
		<pubDate>Mon, 06 Apr 2009 17:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lab49.com/archives/2984#comment-113110</guid>
		<description>Whoa.

Seems like incremental update is only accessible to the brainiest 1% of the planet when using functional languages.

The rest simply use a[i].x += 5 or somesuch, with need for fingers or zippers or a PhD.</description>
		<content:encoded><![CDATA[<p>Whoa.</p>
<p>Seems like incremental update is only accessible to the brainiest 1% of the planet when using functional languages.</p>
<p>The rest simply use a[i].x += 5 or somesuch, with need for fingers or zippers or a PhD.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

