Commit a533fa4
ODT reader: rewrite in monadic style instead of arrows.
The ODT reader was written in an idiosyncratic arrows-based style,
using a custom ArrowState arrow and dozens of special combinators.
Replace this with an ordinary monad:
type XMLConverter nsID extraState
= ExceptT () (State (XMLConverterState nsID extraState))
This preserves the original semantics (state changes persist through
failure; recovery via Alternative's <|>) while allowing all readers
to be written in plain do/applicative notation.
- Rewrite Generic/XMLConverter.hs around the new monad; replace the
parent-element stack with a single currentElement field, and make
matchContent matchers simple (namespace, name, reader) triples
whose results are mconcat'd in document order.
- Port StyleReader.hs and ContentReader.hs to monadic style.
- constructList now runs its child reader once instead of twice.
- Delete Arrows/State.hs, Arrows/Utils.hs, and Base.hs; trim
Generic/Fallible.hs and Generic/Utils.hs to what is still used.
Net -994 lines. No changes to test output.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 1791dd8 commit a533fa4
10 files changed
Lines changed: 777 additions & 1771 deletions
File tree
- src/Text/Pandoc/Readers
- ODT
- Arrows
- Generic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
775 | 774 | | |
776 | 775 | | |
777 | 776 | | |
| |||
780 | 779 | | |
781 | 780 | | |
782 | 781 | | |
783 | | - | |
784 | | - | |
785 | 782 | | |
786 | 783 | | |
787 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
This file was deleted.
0 commit comments