jgm/pandoc — pull request #1366 by jkr (2014-06-23 21:18:14+00:00)
Title: Docx rewrite and cleanup (in terms of Reducible typeclass)

This patchset represents a rather large rewrite of the reader that removes almost all of the tree-walking. The code is a lot shorter, and time on a text-heavy doc is cut by about 2/3 (non-systematic tests).

The key is a new typeclass, `Reducible` that allows Blocks and Inlines to be "reduced", e.g.

~~~
Emph [Strong [Str "foo", Space]] <++> Strong [Emph [Str "bar"]], Str "baz"] =
[Strong [Emph [Str "foo", Space, Str "bar"], Space, Str "baz"]]
~~~

This was what I was unable to do before, which was limiting more efficient construction. Operators for dealing with (Reducible a) => (Many a) (Inlines, Blocks) are also included.

Essentially, it's an abstraction on the old `spanReduce` code, from when everything was turned into a span. Right now the typeclass resides in the T.P.R.Docx dir. If it looks like it may be useful for others, John, feel free to move it. I'm not sure -- it might be pretty niche to docx purposes.