summaryrefslogtreecommitdiffstats
path: root/TreeZipperUtils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'TreeZipperUtils.hs')
-rw-r--r--TreeZipperUtils.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/TreeZipperUtils.hs b/TreeZipperUtils.hs
new file mode 100644
index 0000000..b6410a3
--- /dev/null
+++ b/TreeZipperUtils.hs
@@ -0,0 +1,12 @@
+module TreeZipperUtils where
+
+import Data.Tree
+import Data.Tree.Zipper
+
+-- Return loc (as parent-like structure) and parents.
+path :: TreePos Full a -> [(Forest a, a, Forest a)]
+path loc = toParent loc : parents loc
+
+-- Return parent stack compatible form of loc.
+toParent :: TreePos Full a -> (Forest a, a, Forest a)
+toParent loc = (before loc, label loc, after loc)