    {-# LANGUAGE DeriveTraversable     #-}
    {-# LANGUAGE DerivingStrategies    #-}
    {-# LANGUAGE FlexibleContexts      #-}
    {-# LANGUAGE FlexibleInstances     #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {- |
    Module      : Text.Pandoc.Lua.Walk
    Copyright   : © 2012-2021 John MacFarlane,
                  © 2017-2021 Albert Krewinkel
    License     : GNU GPL, version 2 or above
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>

    Walking documents in a filter-suitable way.
    -}
    module Text.Pandoc.Lua.SpliceList
      ( SpliceList (..)
      )
    where

    import Control.Monad ((<=<))
    import Text.Pandoc.Definition
    import Text.Pandoc.Walk

    -- | Helper type which allows to traverse trees in order, while splicing
    -- in trees.
    --
    -- The only interesting use of this type is via it's '@Walkable@'
    -- instance. That instance makes it possible to walk a Pandoc document
    -- (or a subset thereof), while applying a function on each element of
    -- an AST element /list/, and have the resulting list spliced back in
    -- place of the original element. This is the traversal/splicing method
    -- used for Lua filters.
    newtype SpliceList a = SpliceList { forall a. SpliceList a -> [a]
    unSpliceList :: [a] }
      deriving stock ((forall a b. (a -> b) -> SpliceList a -> SpliceList b)
    -> (forall a b. a -> SpliceList b -> SpliceList a)
    -> Functor SpliceList
    forall a b. a -> SpliceList b -> SpliceList a
    forall a b. (a -> b) -> SpliceList a -> SpliceList b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> SpliceList a -> SpliceList b
    fmap :: forall a b. (a -> b) -> SpliceList a -> SpliceList b
    $c<$ :: forall a b. a -> SpliceList b -> SpliceList a
    <$ :: forall a b. a -> SpliceList b -> SpliceList a
    Functor, (forall m. Monoid m => SpliceList m -> m)
    -> (forall m a. Monoid m => (a -> m) -> SpliceList a -> m)
    -> (forall m a. Monoid m => (a -> m) -> SpliceList a -> m)
    -> (forall a b. (a -> b -> b) -> b -> SpliceList a -> b)
    -> (forall a b. (a -> b -> b) -> b -> SpliceList a -> b)
    -> (forall b a. (b -> a -> b) -> b -> SpliceList a -> b)
    -> (forall b a. (b -> a -> b) -> b -> SpliceList a -> b)
    -> (forall a. (a -> a -> a) -> SpliceList a -> a)
    -> (forall a. (a -> a -> a) -> SpliceList a -> a)
    -> (forall a. SpliceList a -> [a])
    -> (forall a. SpliceList a -> Bool)
    -> (forall a. SpliceList a -> Int)
    -> (forall a. Eq a => a -> SpliceList a -> Bool)
    -> (forall a. Ord a => SpliceList a -> a)
    -> (forall a. Ord a => SpliceList a -> a)
    -> (forall a. Num a => SpliceList a -> a)
    -> (forall a. Num a => SpliceList a -> a)
    -> Foldable SpliceList
    forall a. Eq a => a -> SpliceList a -> Bool
    forall a. Num a => SpliceList a -> a
    forall a. Ord a => SpliceList a -> a
    forall m. Monoid m => SpliceList m -> m
    forall a. SpliceList a -> Bool
    forall a. SpliceList a -> Int
    forall a. SpliceList a -> [a]
    forall a. (a -> a -> a) -> SpliceList a -> a
    forall m a. Monoid m => (a -> m) -> SpliceList a -> m
    forall b a. (b -> a -> b) -> b -> SpliceList a -> b
    forall a b. (a -> b -> b) -> b -> SpliceList a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => SpliceList m -> m
    fold :: forall m. Monoid m => SpliceList m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> SpliceList a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> SpliceList a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> SpliceList a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> SpliceList a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> SpliceList a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> SpliceList a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> SpliceList a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> SpliceList a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> SpliceList a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> SpliceList a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> SpliceList a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> SpliceList a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> SpliceList a -> a
    foldr1 :: forall a. (a -> a -> a) -> SpliceList a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> SpliceList a -> a
    foldl1 :: forall a. (a -> a -> a) -> SpliceList a -> a
    $ctoList :: forall a. SpliceList a -> [a]
    toList :: forall a. SpliceList a -> [a]
    $cnull :: forall a. SpliceList a -> Bool
    null :: forall a. SpliceList a -> Bool
    $clength :: forall a. SpliceList a -> Int
    length :: forall a. SpliceList a -> Int
    $celem :: forall a. Eq a => a -> SpliceList a -> Bool
    elem :: forall a. Eq a => a -> SpliceList a -> Bool
    $cmaximum :: forall a. Ord a => SpliceList a -> a
    maximum :: forall a. Ord a => SpliceList a -> a
    $cminimum :: forall a. Ord a => SpliceList a -> a
    minimum :: forall a. Ord a => SpliceList a -> a
    $csum :: forall a. Num a => SpliceList a -> a
    sum :: forall a. Num a => SpliceList a -> a
    $cproduct :: forall a. Num a => SpliceList a -> a
    product :: forall a. Num a => SpliceList a -> a
    Foldable, Functor SpliceList
    Foldable SpliceList
    (Functor SpliceList, Foldable SpliceList) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> SpliceList a -> f (SpliceList b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        SpliceList (f a) -> f (SpliceList a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> SpliceList a -> m (SpliceList b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        SpliceList (m a) -> m (SpliceList a))
    -> Traversable SpliceList
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a.
    Monad m =>
    SpliceList (m a) -> m (SpliceList a)
    forall (f :: * -> *) a.
    Applicative f =>
    SpliceList (f a) -> f (SpliceList a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> SpliceList a -> m (SpliceList b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> SpliceList a -> f (SpliceList b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> SpliceList a -> f (SpliceList b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> SpliceList a -> f (SpliceList b)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    SpliceList (f a) -> f (SpliceList a)
    sequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    SpliceList (f a) -> f (SpliceList a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> SpliceList a -> m (SpliceList b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> SpliceList a -> m (SpliceList b)
    $csequence :: forall (m :: * -> *) a.
    Monad m =>
    SpliceList (m a) -> m (SpliceList a)
    sequence :: forall (m :: * -> *) a.
    Monad m =>
    SpliceList (m a) -> m (SpliceList a)
    Traversable)

    --
    -- SpliceList Inline
    --
    instance {-# OVERLAPPING #-} Walkable (SpliceList Inline) [Inline] where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> [Inline] -> m [Inline]
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> [Inline] -> m [Inline]
    forall (m :: * -> *) a.
    (Monad m, Walkable (SpliceList a) a) =>
    (SpliceList a -> m (SpliceList a)) -> [a] -> m [a]
    walkSpliceListM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> [Inline] -> c
    query = (SpliceList Inline -> c) -> [Inline] -> c
    forall c a.
    (Monoid c, Walkable (SpliceList a) a) =>
    (SpliceList a -> c) -> [a] -> c
    querySpliceList

    instance Walkable (SpliceList Inline) Pandoc where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Pandoc -> m Pandoc
    walkM = (SpliceList Inline -> m (SpliceList Inline)) -> Pandoc -> m Pandoc
    forall a (m :: * -> *).
    (Walkable a Meta, Walkable a [Block], Monad m, Applicative m,
     Functor m) =>
    (a -> m a) -> Pandoc -> m Pandoc
    walkPandocM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Pandoc -> c
    query = (SpliceList Inline -> c) -> Pandoc -> c
    forall a c.
    (Walkable a Meta, Walkable a [Block], Monoid c) =>
    (a -> c) -> Pandoc -> c
    queryPandoc

    instance Walkable (SpliceList Inline) Citation where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> Citation -> m Citation
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> Citation -> m Citation
    forall a (m :: * -> *).
    (Walkable a [Inline], Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Citation -> m Citation
    walkCitationM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Citation -> c
    query = (SpliceList Inline -> c) -> Citation -> c
    forall a c.
    (Walkable a [Inline], Monoid c) =>
    (a -> c) -> Citation -> c
    queryCitation

    instance Walkable (SpliceList Inline) Inline where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Inline -> m Inline
    walkM = (SpliceList Inline -> m (SpliceList Inline)) -> Inline -> m Inline
    forall a (m :: * -> *).
    (Walkable a Citation, Walkable a [Block], Walkable a [Inline],
     Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Inline -> m Inline
    walkInlineM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Inline -> c
    query = (SpliceList Inline -> c) -> Inline -> c
    forall a c.
    (Walkable a Citation, Walkable a [Block], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> Inline -> c
    queryInline

    instance Walkable (SpliceList Inline) Block where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Block -> m Block
    walkM = (SpliceList Inline -> m (SpliceList Inline)) -> Block -> m Block
    forall a (m :: * -> *).
    (Walkable a [Block], Walkable a [Inline], Walkable a Row,
     Walkable a Caption, Walkable a TableHead, Walkable a TableBody,
     Walkable a TableFoot, Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Block -> m Block
    walkBlockM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Block -> c
    query = (SpliceList Inline -> c) -> Block -> c
    forall a c.
    (Walkable a Citation, Walkable a [Block], Walkable a Row,
     Walkable a Caption, Walkable a TableHead, Walkable a TableBody,
     Walkable a TableFoot, Walkable a [Inline], Monoid c) =>
    (a -> c) -> Block -> c
    queryBlock

    instance Walkable (SpliceList Inline) Row where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Row -> m Row
    walkM = (SpliceList Inline -> m (SpliceList Inline)) -> Row -> m Row
    forall a (m :: * -> *).
    (Walkable a Cell, Monad m) =>
    (a -> m a) -> Row -> m Row
    walkRowM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Row -> c
    query = (SpliceList Inline -> c) -> Row -> c
    forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
    queryRow

    instance Walkable (SpliceList Inline) TableHead where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> TableHead -> m TableHead
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> TableHead -> m TableHead
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableHead -> m TableHead
    walkTableHeadM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> TableHead -> c
    query = (SpliceList Inline -> c) -> TableHead -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableHead -> c
    queryTableHead

    instance Walkable (SpliceList Inline) TableBody where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> TableBody -> m TableBody
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> TableBody -> m TableBody
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableBody -> m TableBody
    walkTableBodyM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> TableBody -> c
    query = (SpliceList Inline -> c) -> TableBody -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableBody -> c
    queryTableBody

    instance Walkable (SpliceList Inline) TableFoot where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> TableFoot -> m TableFoot
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> TableFoot -> m TableFoot
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableFoot -> m TableFoot
    walkTableFootM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> TableFoot -> c
    query = (SpliceList Inline -> c) -> TableFoot -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableFoot -> c
    queryTableFoot

    instance Walkable (SpliceList Inline) Caption where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> Caption -> m Caption
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> Caption -> m Caption
    forall a (m :: * -> *).
    (Walkable a [Block], Walkable a [Inline], Monad m,
     Walkable a [Inline]) =>
    (a -> m a) -> Caption -> m Caption
    walkCaptionM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Caption -> c
    query = (SpliceList Inline -> c) -> Caption -> c
    forall a c.
    (Walkable a [Block], Walkable a [Inline], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> Caption -> c
    queryCaption

    instance Walkable (SpliceList Inline) Cell where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Cell -> m Cell
    walkM = (SpliceList Inline -> m (SpliceList Inline)) -> Cell -> m Cell
    forall a (m :: * -> *).
    (Walkable a [Block], Monad m) =>
    (a -> m a) -> Cell -> m Cell
    walkCellM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Cell -> c
    query = (SpliceList Inline -> c) -> Cell -> c
    forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
    queryCell

    instance Walkable (SpliceList Inline) MetaValue where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> MetaValue -> m MetaValue
    walkM = (SpliceList Inline -> m (SpliceList Inline))
    -> MetaValue -> m MetaValue
    forall a (f :: * -> *).
    (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline],
     Monad f, Applicative f, Functor f) =>
    (a -> f a) -> MetaValue -> f MetaValue
    walkMetaValueM
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> MetaValue -> c
    query = (SpliceList Inline -> c) -> MetaValue -> c
    forall a c.
    (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> MetaValue -> c
    queryMetaValue

    instance Walkable (SpliceList Inline) Meta where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline)) -> Meta -> m Meta
    walkM SpliceList Inline -> m (SpliceList Inline)
    f (Meta Map Text MetaValue
    metamap) = Map Text MetaValue -> Meta
    Meta (Map Text MetaValue -> Meta) -> m (Map Text MetaValue) -> m Meta
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (SpliceList Inline -> m (SpliceList Inline))
    -> Map Text MetaValue -> m (Map Text MetaValue)
    forall a b (m :: * -> *).
    (Walkable a b, Monad m, Applicative m, Functor m) =>
    (a -> m a) -> b -> m b
    forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Inline -> m (SpliceList Inline))
    -> Map Text MetaValue -> m (Map Text MetaValue)
    walkM SpliceList Inline -> m (SpliceList Inline)
    f Map Text MetaValue
    metamap
      query :: forall c. Monoid c => (SpliceList Inline -> c) -> Meta -> c
    query SpliceList Inline -> c
    f (Meta Map Text MetaValue
    metamap) = (SpliceList Inline -> c) -> Map Text MetaValue -> c
    forall c.
    Monoid c =>
    (SpliceList Inline -> c) -> Map Text MetaValue -> c
    forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
    query SpliceList Inline -> c
    f Map Text MetaValue
    metamap

    --
    -- SpliceList Block
    --
    instance {-# OVERLAPPING #-} Walkable (SpliceList Block) [Block] where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> [Block] -> m [Block]
    walkM = (SpliceList Block -> m (SpliceList Block)) -> [Block] -> m [Block]
    forall (m :: * -> *) a.
    (Monad m, Walkable (SpliceList a) a) =>
    (SpliceList a -> m (SpliceList a)) -> [a] -> m [a]
    walkSpliceListM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> [Block] -> c
    query = (SpliceList Block -> c) -> [Block] -> c
    forall c a.
    (Monoid c, Walkable (SpliceList a) a) =>
    (SpliceList a -> c) -> [a] -> c
    querySpliceList

    instance Walkable (SpliceList Block) Pandoc where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Pandoc -> m Pandoc
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Pandoc -> m Pandoc
    forall a (m :: * -> *).
    (Walkable a Meta, Walkable a [Block], Monad m, Applicative m,
     Functor m) =>
    (a -> m a) -> Pandoc -> m Pandoc
    walkPandocM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Pandoc -> c
    query = (SpliceList Block -> c) -> Pandoc -> c
    forall a c.
    (Walkable a Meta, Walkable a [Block], Monoid c) =>
    (a -> c) -> Pandoc -> c
    queryPandoc

    instance Walkable (SpliceList Block) Citation where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> Citation -> m Citation
    walkM = (SpliceList Block -> m (SpliceList Block))
    -> Citation -> m Citation
    forall a (m :: * -> *).
    (Walkable a [Inline], Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Citation -> m Citation
    walkCitationM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Citation -> c
    query = (SpliceList Block -> c) -> Citation -> c
    forall a c.
    (Walkable a [Inline], Monoid c) =>
    (a -> c) -> Citation -> c
    queryCitation

    instance Walkable (SpliceList Block) Inline where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Inline -> m Inline
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Inline -> m Inline
    forall a (m :: * -> *).
    (Walkable a Citation, Walkable a [Block], Walkable a [Inline],
     Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Inline -> m Inline
    walkInlineM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Inline -> c
    query = (SpliceList Block -> c) -> Inline -> c
    forall a c.
    (Walkable a Citation, Walkable a [Block], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> Inline -> c
    queryInline

    instance Walkable (SpliceList Block) Block where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Block -> m Block
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Block -> m Block
    forall a (m :: * -> *).
    (Walkable a [Block], Walkable a [Inline], Walkable a Row,
     Walkable a Caption, Walkable a TableHead, Walkable a TableBody,
     Walkable a TableFoot, Monad m, Applicative m, Functor m) =>
    (a -> m a) -> Block -> m Block
    walkBlockM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Block -> c
    query = (SpliceList Block -> c) -> Block -> c
    forall a c.
    (Walkable a Citation, Walkable a [Block], Walkable a Row,
     Walkable a Caption, Walkable a TableHead, Walkable a TableBody,
     Walkable a TableFoot, Walkable a [Inline], Monoid c) =>
    (a -> c) -> Block -> c
    queryBlock

    instance Walkable (SpliceList Block) Row where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Row -> m Row
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Row -> m Row
    forall a (m :: * -> *).
    (Walkable a Cell, Monad m) =>
    (a -> m a) -> Row -> m Row
    walkRowM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Row -> c
    query = (SpliceList Block -> c) -> Row -> c
    forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
    queryRow

    instance Walkable (SpliceList Block) TableHead where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> TableHead -> m TableHead
    walkM = (SpliceList Block -> m (SpliceList Block))
    -> TableHead -> m TableHead
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableHead -> m TableHead
    walkTableHeadM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> TableHead -> c
    query = (SpliceList Block -> c) -> TableHead -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableHead -> c
    queryTableHead

    instance Walkable (SpliceList Block) TableBody where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> TableBody -> m TableBody
    walkM = (SpliceList Block -> m (SpliceList Block))
    -> TableBody -> m TableBody
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableBody -> m TableBody
    walkTableBodyM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> TableBody -> c
    query = (SpliceList Block -> c) -> TableBody -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableBody -> c
    queryTableBody

    instance Walkable (SpliceList Block) TableFoot where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> TableFoot -> m TableFoot
    walkM = (SpliceList Block -> m (SpliceList Block))
    -> TableFoot -> m TableFoot
    forall a (m :: * -> *).
    (Walkable a Row, Monad m) =>
    (a -> m a) -> TableFoot -> m TableFoot
    walkTableFootM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> TableFoot -> c
    query = (SpliceList Block -> c) -> TableFoot -> c
    forall a c.
    (Walkable a Row, Monoid c) =>
    (a -> c) -> TableFoot -> c
    queryTableFoot

    instance Walkable (SpliceList Block) Caption where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Caption -> m Caption
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Caption -> m Caption
    forall a (m :: * -> *).
    (Walkable a [Block], Walkable a [Inline], Monad m,
     Walkable a [Inline]) =>
    (a -> m a) -> Caption -> m Caption
    walkCaptionM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Caption -> c
    query = (SpliceList Block -> c) -> Caption -> c
    forall a c.
    (Walkable a [Block], Walkable a [Inline], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> Caption -> c
    queryCaption

    instance Walkable (SpliceList Block) Cell where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Cell -> m Cell
    walkM = (SpliceList Block -> m (SpliceList Block)) -> Cell -> m Cell
    forall a (m :: * -> *).
    (Walkable a [Block], Monad m) =>
    (a -> m a) -> Cell -> m Cell
    walkCellM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Cell -> c
    query = (SpliceList Block -> c) -> Cell -> c
    forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
    queryCell

    instance Walkable (SpliceList Block) MetaValue where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> MetaValue -> m MetaValue
    walkM = (SpliceList Block -> m (SpliceList Block))
    -> MetaValue -> m MetaValue
    forall a (f :: * -> *).
    (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline],
     Monad f, Applicative f, Functor f) =>
    (a -> f a) -> MetaValue -> f MetaValue
    walkMetaValueM
      query :: forall c. Monoid c => (SpliceList Block -> c) -> MetaValue -> c
    query = (SpliceList Block -> c) -> MetaValue -> c
    forall a c.
    (Walkable a MetaValue, Walkable a [Block], Walkable a [Inline],
     Monoid c) =>
    (a -> c) -> MetaValue -> c
    queryMetaValue

    instance Walkable (SpliceList Block) Meta where
      walkM :: forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block)) -> Meta -> m Meta
    walkM SpliceList Block -> m (SpliceList Block)
    f (Meta Map Text MetaValue
    metamap) = Map Text MetaValue -> Meta
    Meta (Map Text MetaValue -> Meta) -> m (Map Text MetaValue) -> m Meta
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (SpliceList Block -> m (SpliceList Block))
    -> Map Text MetaValue -> m (Map Text MetaValue)
    forall a b (m :: * -> *).
    (Walkable a b, Monad m, Applicative m, Functor m) =>
    (a -> m a) -> b -> m b
    forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList Block -> m (SpliceList Block))
    -> Map Text MetaValue -> m (Map Text MetaValue)
    walkM SpliceList Block -> m (SpliceList Block)
    f Map Text MetaValue
    metamap
      query :: forall c. Monoid c => (SpliceList Block -> c) -> Meta -> c
    query SpliceList Block -> c
    f (Meta Map Text MetaValue
    metamap) = (SpliceList Block -> c) -> Map Text MetaValue -> c
    forall c.
    Monoid c =>
    (SpliceList Block -> c) -> Map Text MetaValue -> c
    forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
    query SpliceList Block -> c
    f Map Text MetaValue
    metamap

    walkSpliceListM :: (Monad m, Walkable (SpliceList a) a)
                    => (SpliceList a -> m (SpliceList a))
                    -> [a] -> m [a]
    walkSpliceListM :: forall (m :: * -> *) a.
    (Monad m, Walkable (SpliceList a) a) =>
    (SpliceList a -> m (SpliceList a)) -> [a] -> m [a]
    walkSpliceListM SpliceList a -> m (SpliceList a)
    f =
      let f' :: a -> m [a]
    f' = (SpliceList a -> [a]) -> m (SpliceList a) -> m [a]
    forall a b. (a -> b) -> m a -> m b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap SpliceList a -> [a]
    forall a. SpliceList a -> [a]
    unSpliceList (m (SpliceList a) -> m [a])
    -> (a -> m (SpliceList a)) -> a -> m [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SpliceList a -> m (SpliceList a)
    f (SpliceList a -> m (SpliceList a))
    -> (a -> SpliceList a) -> a -> m (SpliceList a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [a] -> SpliceList a
    forall a. [a] -> SpliceList a
    SpliceList ([a] -> SpliceList a) -> (a -> [a]) -> a -> SpliceList a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    :[]) (a -> m [a]) -> (a -> m a) -> a -> m [a]
    forall (m :: * -> *) b c a.
    Monad m =>
    (b -> m c) -> (a -> m b) -> a -> m c
    <=< (SpliceList a -> m (SpliceList a)) -> a -> m a
    forall a b (m :: * -> *).
    (Walkable a b, Monad m, Applicative m, Functor m) =>
    (a -> m a) -> b -> m b
    forall (m :: * -> *).
    (Monad m, Applicative m, Functor m) =>
    (SpliceList a -> m (SpliceList a)) -> a -> m a
    walkM SpliceList a -> m (SpliceList a)
    f
      in ([[a]] -> [a]) -> m [[a]] -> m [a]
    forall a b. (a -> b) -> m a -> m b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [[a]] -> [a]
    forall a. Monoid a => [a] -> a
    mconcat (m [[a]] -> m [a]) -> ([a] -> m [[a]]) -> [a] -> m [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> m [a]) -> [a] -> m [[a]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
    mapM a -> m [a]
    f'

    querySpliceList :: (Monoid c, Walkable (SpliceList a) a)
                    => (SpliceList a -> c)
                    -> [a] -> c
    querySpliceList :: forall c a.
    (Monoid c, Walkable (SpliceList a) a) =>
    (SpliceList a -> c) -> [a] -> c
    querySpliceList SpliceList a -> c
    f =
      let f' :: a -> c
    f' a
    x = SpliceList a -> c
    f ([a] -> SpliceList a
    forall a. [a] -> SpliceList a
    SpliceList [a
    x]) c -> c -> c
    forall a. Monoid a => a -> a -> a
    `mappend` (SpliceList a -> c) -> a -> c
    forall c. Monoid c => (SpliceList a -> c) -> a -> c
    forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
    query SpliceList a -> c
    f a
    x
      in [c] -> c
    forall a. Monoid a => [a] -> a
    mconcat ([c] -> c) -> ([a] -> [c]) -> [a] -> c
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> c) -> [a] -> [c]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> c
    f'