So the problem seems not to be CSE algorithm, but the fact that EDSL itself tends to blow up because it is hosted in Haskell.</blockquote><div><br>In other words, the tree size blows up, and hosting in pure Haskell doesn&#39;t allow us to examine the compact dag.<br>

</blockquote>
<br></div>
What do you mean with `exponential behavior&#39;? Exponential related to what?<br>
<br>
For my FRP EDSL to JavaScript (toy) compiler[1] I&#39;ve been implementing CSE as well. I traverses the expression tree recursively and creates an small intermediate language containing id&#39;s (pointers) to expressions instead of real sub-expressions.<br>

<br>
Maybe (probably) I am very naive, but I think this trick takes time linear to the amount of sub-expressions in my script. When using a trie instead of a binary tree for the comparisons there should be no more character (or atomic expression) comparisons that the amount of characters in the script.<br>