Hello,<br><br>If I use zippers, do all my nodes need to be the same type? My tree doesn't have the same type for every node. For example:<br><br>Modules -> Module -> Types -> Type -> Members -> Member -> Type -> ...<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"><<a href="mailto:miguelimo38@yandex.ru">miguelimo38@yandex.ru</a>></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'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 <<a href="mailto:haskell@colquitt.org" target="_blank">haskell@colquitt.org</a>> wrote:<br>
John,<br>
<br>
> Is it possible to create a circular pure data structure in Haskell? For<br>
> 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' = 1 : ones'<br>
<br>
Comparing these values is harder. All of (ones), (ones'), (tail ones), and<br>
so forth are equal values. But I don't know how to compare them. My<br>
Spidey-sense tells me there's probably a simple proof that you can't, if you<br>
care about the comparison terminating.<br>
<br>
"Pointer equality" (ie. testing if the values are represented by the same<br>
bits in memory) is no good, since it's entirely up to the compiler whether<br>
ones and ones' use the same bits. (They won't, but that's not important.)<br>
In general "pointer equality" 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'm sure there'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>