go _k f (TreeN k ts) = TreeN k (go (Just k) f <$> ts)
go k f (Tree0 a) = Tree0 (f k a)
+mapTreeKey :: (k -> l) -> (Maybe k -> a -> b) -> Tree k a -> Tree l b
+mapTreeKey fk fv = go Nothing
+ where
+ go _k (TreeN k ts) = TreeN (fk k) $ go (Just k) <$> ts
+ go k (Tree0 a) = Tree0 (fv k a)
+
traverseTreeWithKey :: Applicative f => (Maybe k -> a -> f b) -> Tree k a -> f (Tree k b)
traverseTreeWithKey = go Nothing
where
pos0 :: Pos
pos0 = Pos 0 0
+pos1 :: Pos
+pos1 = Pos 1 1
-- ** Type 'Line'
-- | Line in the source file, counting from 1.
cell0 :: a -> Cell a
cell0 = Cell pos0 pos0
+cell1 :: a -> Cell a
+cell1 = Cell pos1 pos1
-- * Type 'Key'
data Key = KeyColon !Name !White -- ^ @name: @ begin 'Cell'
| KeyLower !Name !Attrs -- ^ @<name a=b@ begin HereDoc
| KeyDot !Name -- ^ @1. @ begin item
| KeyDash -- ^ @- @ begin item
+ | KeyDashDash -- ^ @-- @ begin item
| KeySection !LevelSection -- ^ @### @ begin section
deriving (Eq, Show)