Hello,<br><br>If I use zippers, do all my nodes need to be the same type?  My tree doesn&#39;t have the same type for every node.  For example:<br><br>Modules -&gt; Module -&gt; Types -&gt; Type -&gt; Members -&gt; Member -&gt; Type -&gt; ...<br>
<br>Thanks<br><br>-John<br><br><div class="gmail_quote">On Wed, Jul 15, 2009 at 2:41 PM, Miguel Mitrofanov <span dir="ltr">&lt;<a href="mailto:miguelimo38@yandex.ru">miguelimo38@yandex.ru</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sufficient, but not good.<br>
<br>
Try zippers instead.<div><div></div><div class="h5"><br>
<br>
On 15 Jul 2009, at 08:29, John Ky wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward.  I didn&#39;t actually care for equality.<br>
<br>
I think the tying the knot technique as mentioned by others is sufficient for this purpose.<br>
<br>
Cheers,<br>
<br>
-John<br>
<br>
On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey &lt;<a href="mailto:haskell@colquitt.org" target="_blank">haskell@colquitt.org</a>&gt; wrote:<br>
John,<br>
<br>
&gt; Is it possible to create a circular pure data structure in Haskell?  For<br>
&gt; example:<br>
<br>
Creating the data structure is easy; as other respondents have pointed out.<br>
A simple example is this...<br>
<br>
ones  = 1 : ones<br>
ones&#39; = 1 : ones&#39;<br>
<br>
Comparing these values is harder.  All of (ones), (ones&#39;), (tail ones), and<br>
so forth are equal values.  But I don&#39;t know how to compare them.  My<br>
Spidey-sense tells me there&#39;s probably a simple proof that you can&#39;t, if you<br>
care about the comparison terminating.<br>
<br>
&quot;Pointer equality&quot; (ie. testing if the values are represented by the same<br>
bits in memory) is no good, since it&#39;s entirely up to the compiler whether<br>
ones and ones&#39; use the same bits.  (They won&#39;t, but that&#39;s not important.)<br>
In general &quot;pointer equality&quot; of Haskell values, such as ones and (tail<br>
ones) interferes with referential transparency, which is held in high<br>
regard around here.  Although, for the record, when pointer equality is<br>
really what you want, I&#39;m sure there&#39;s ways to Force It.<br>
<br>
For your purposes, does it matter if you can actually do the comparison?  Is<br>
it enough to know that ones and (tail ones) are equal?<br>
<br>
Regards,<br>
John<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br>