forked from snoyberg/xml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Eq & Ord instances to Cursor snoyberg#117
Adding derived instances of Eq & Ord requires modifying the inner workings of Cursor record (from the module Text.XML.Cursor.Generic), specifically: Siblings in Cursor were represented as functions (type synonym DiffCursor) that repeatedly append to a (presumably, empty) list until the desired list of nodes is generated. Such a function would later be invoked in various public top-level definitions in the module, but upon an empty list value exclusively. We rename Cursor to RecursiveCursor and add an eval function that evaluates a RecursiveCursor to a simpler data structure that takes the place of Cursor in the module interface. Then, we simplify the aforementioned public functions, replacing the invocations of DiffCursor upon an empty list by plain (nullary) values stored in our new, simpler Cursor data structure. Thus, we obtain a simpler data structure while preserving the interface. As the new Cursor data structure is free of functions, an Eq & Ord instance is now readily derivable.
- Loading branch information
Showing
1 changed file
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters