-- | Map over the holes in a 'Markup'. This necessarily discards any attributes
-- currently being added that are not static.
mapP :: (a -> b) -> Markup a r -> Markup b r
mapP f (Markup m) = Markup $ \i attr -> case m i (foldr addA [] attr) of
  ms -> ms { msChildren = \cs -> map (fmap f) (msChildren ms []) ++ cs }
  where
    addA ((:=) a b) xs = (a := b) : xs
    addA _          xs = xs
mapP :: (a -> b) -> Markup a r -> Markup b r
mapP f (Markup m) = Markup $ \i attr -> case m i (foldr addA [] attr) of
  ms -> ms { msChildren = \cs -> map (fmap f) (msChildren ms []) ++ cs }
  where
    addA ((:=) a b) xs = (a := b) : xs
    addA _          xs = xs
mapP f (Markup m) = Markup $ \i attr -> case m i (foldr addA [] attr) of
  ms -> ms { msChildren = \cs -> map (fmap f) (msChildren ms []) ++ cs }
  where
    addA ((:=) a b) xs = (a := b) : xs
    addA _          xs = xs