On Thu, Jun 9, 2011 at 6:04 PM, Felipe Almeida Lessa <span dir="ltr"><<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Something like this?<br>
<br>
equivalenceClosure = fix $ \f e -><br>
let e' = reflexivity . symmetry . transitivity $ e<br>
in if e' == e then e else f e'<br>
<br>
Cheers,<br>
<br>
--<br>
<font color="#888888">Felipe.<br>
</font></blockquote></div><br><div><div>I managed something even "clearer". I still have very little intuition about what's going on, but I had an aha moment -- which I promptly forgot :0( -- and at least there's a mechanical translation from the iterate version to the fix one.</div>
<div><br></div><div>equivalenceClosure :: (Ord a) => Relation a -> Relation a</div><div>equivalenceClosure = fix (\f -> reflexivity . symmetry . transitivity)</div></div>