Add GNUmakefile profiling targets.
[doclang.git] / Language / TCT / Tree.hs
index 9058e3169d1cd45e9721f8ef137e36d20046de87..a63efd46db08d1257267a970a34b20fc3a500234 100644 (file)
@@ -44,6 +44,12 @@ mapTreeWithKey = go Nothing
        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
@@ -88,6 +94,8 @@ posEndTree (Tree0 c)   = posEndCell c
 
 pos0 :: Pos
 pos0 = Pos 0 0
+pos1 :: Pos
+pos1 = Pos 1 1
 
 -- ** Type 'Line'
 -- | Line in the source file, counting from 1.
@@ -128,6 +136,8 @@ columnCell = columnPos . posCell
 
 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'
@@ -137,6 +147,7 @@ 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)