Note that data-reify will only find *some* common/equal sub-expressions, namely the pointer-equal ones. In all of my code-generating ("deep") DSLs, it's been very important for efficiency to also pull out equal-but-pointer-unequal expressions.<br>
<br> - Conal<br><br><div class="gmail_quote">On Thu, Aug 11, 2011 at 4:41 AM, Vo Minh Thu <span dir="ltr"><<a href="mailto:noteed@gmail.com" target="_blank">noteed@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I guess you refer to data-reify:<br>
<a href="http://hackage.haskell.org/package/data-reify" target="_blank">http://hackage.haskell.org/package/data-reify</a><br>
<br>
2011/8/11 Stephen Tetley <<a href="mailto:stephen.tetley@gmail.com" target="_blank">stephen.tetley@gmail.com</a>>:<br>
<div><div></div><div>> Strafunski and its successors (Uniplate, SYB, KURE) are really for<br>
> working on trees. If you want to work on graphs you would probably be<br>
> better of with something else.<br>
><br>
> I think I overlooked that you want common sub-expression<br>
> _elimination_, rather than expression simplification. There are<br>
> libraries for observable sharing (Andy Gill's recent one is the<br>
> state-of-the-art, its on Hackage but I've forgotten its name) - that<br>
> are pertinent where you have built the expressions as an embedded DSL<br>
> in Haskell and you want sharing in code you generate from the Haskell<br>
> DSL.<br>
><br>
><br>
><br>
> On 11 August 2011 08:57, Anton Kholomiov <<a href="mailto:anton.kholomiov@gmail.com" target="_blank">anton.kholomiov@gmail.com</a>> wrote:<br>
>> Thank you for the reference to Strafunski libraries, I read<br>
>> HaskellWiki, but I don't have a permission to visit their site.<br>
>> All links are forbidden.<br>
>><br>
>> Can it be a function:<br>
>><br>
>> fun :: Eq a => Tree a -> [(Int, (a, [Int]))]<br>
>><br>
>> where tuple codes nodes, and Int's code edges.<br>
>><br>
>> 2011/8/11 Stephen Tetley <<a href="mailto:stephen.tetley@gmail.com" target="_blank">stephen.tetley@gmail.com</a>><br>
>>><br>
>>> Wouldn't this be dependent upon your AST and thus not readily<br>
>>> "package-able" as a library?<br>
>>><br>
>>> Expression simplification has been a prime example for Strafunski<br>
>>> style traversal libraries. You might be able to find examples that you<br>
>>> can adapt to your own AST written with Uniplate or similar library.<br>
>>><br>
>>> On 11 August 2011 05:00, Anton Kholomiov <<a href="mailto:anton.kholomiov@gmail.com" target="_blank">anton.kholomiov@gmail.com</a>><br>
>>> wrote:<br>
>>> > Is there a library on common sub-expression elimination?<br>
>>> ><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>
>> _______________________________________________<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>
><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>
_______________________________________________<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>
</div></div></blockquote></div><br>