Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.haskell.org/ghc/docs/6.12-latest/html/libraries/containers-0.3.0.0/src/Data-Sequence.html#applicativeTree" rel="nofollow noreferrer"><code>applicativeTree</code></a> is quite fancy, but mainly in a way which has to do with FingerTrees in particular, which are quite a fancy data structure themselves. We had some discussion of the intricacies <a href="https://cstheory.stackexchange.com/q/5356">over at cstheory</a>. Note that <code>applicativeTree</code> is written to work over <em>any</em> Applicative. It just so happens that when it is specialized to <code>Id</code> then it can share nodes in a manner that it otherwise couldn't. You can work through the specialization yourself by inlining the <code>Id</code> methods and seeing what happens. Note that this specialization is used in only one place -- the O(log n) <code>replicate</code> function. The fact that the more general function specializes neatly to the constant case is a very clever bit of code reuse, but that's really all.</p> <p>In general, <code>Sequence</code> teaches more about designing persistent data structures than about all the tricks for eeking out performance, I think. Dons' suggestions are of course excellent. I'd also just browse through the source of the <em>really</em> canonical and tuned libs -- <code>Map</code>, <code>IntMap</code>, <code>Set</code>, and <code>IntSet</code> in particular. Along with those, its worth taking a look at Milan's <a href="http://fox.ucw.cz/papers/containers/containers.pdf" rel="nofollow noreferrer">paper on his improvements to containers</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload