{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE CPP #-}
#if MIN_VERSION_base(4,9,0)
{-# OPTIONS_GHC -fno-warn-redundant-constraints -O2 #-}
#endif
#define OVERLAPS {-# OVERLAPPING #-}
module Text.Pandoc.Walk
( Walkable(..)
, queryBlock
, queryCaption
, queryRow
, queryTableHead
, queryTableBody
, queryTableFoot
, queryCell
, queryCitation
, queryInline
, queryMetaValue
, queryMetaValue'
, queryPandoc
, walkBlockM
, walkCaptionM
, walkRowM
, walkTableHeadM
, walkTableBodyM
, walkTableFootM
, walkCellM
, walkCitationM
, walkInlineM
, walkMetaValueM
, walkMetaValueM'
, walkPandocM
)
where
import Control.Applicative (Applicative ((<*>), pure), (<$>))
import Control.Monad ((>=>))
import Data.Functor.Identity (Identity (runIdentity))
import qualified Data.Map as M
import Text.Pandoc.Definition
import qualified Data.Traversable as T
import Data.Traversable (Traversable)
import qualified Data.Foldable as F
import Data.Foldable (Foldable)
import Data.Monoid ((<>))
class Walkable a b where
walk :: (a -> a) -> b -> b
walk a -> a
f = Identity b -> b
forall a. Identity a -> a
runIdentity (Identity b -> b) -> (b -> Identity b) -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> b -> Identity b
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM (a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Identity a) -> (a -> a) -> a -> Identity a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
f)
walkM :: (Monad m, Applicative m, Functor m) => (a -> m a) -> b -> m b
query :: Monoid c => (a -> c) -> b -> c
{-# MINIMAL walkM, query #-}
instance (Foldable t, Traversable t, Walkable a b) => Walkable a (t b) where
walk :: (a -> a) -> t b -> t b
walk a -> a
f = (b -> b) -> t b -> t b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
T.fmapDefault ((a -> a) -> b -> b
forall a b. Walkable a b => (a -> a) -> b -> b
walk a -> a
f)
walkM :: (a -> m a) -> t b -> m (t b)
walkM a -> m a
f = (b -> m b) -> t b -> m (t b)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
T.mapM ((a -> m a) -> b -> m b
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f)
query :: (a -> c) -> t b -> c
query a -> c
f = (b -> c) -> t b -> c
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap ((a -> c) -> b -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f)
instance OVERLAPS
(Walkable a b, Walkable a c) => Walkable a (b,c) where
walk :: (a -> a) -> (b, c) -> (b, c)
walk a -> a
f (b
x,c
y) = ((a -> a) -> b -> b
forall a b. Walkable a b => (a -> a) -> b -> b
walk a -> a
f b
x, (a -> a) -> c -> c
forall a b. Walkable a b => (a -> a) -> b -> b
walk a -> a
f c
y)
walkM :: (a -> m a) -> (b, c) -> m (b, c)
walkM a -> m a
f (b
x,c
y) = do b
x' <- (a -> m a) -> b -> m b
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f b
x
c
y' <- (a -> m a) -> c -> m c
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f c
y
(b, c) -> m (b, c)
forall (m :: * -> *) a. Monad m => a -> m a
return (b
x',c
y')
query :: (a -> c) -> (b, c) -> c
query a -> c
f (b
x,c
y) = c -> c -> c
forall a. Monoid a => a -> a -> a
mappend ((a -> c) -> b -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f b
x) ((a -> c) -> c -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f c
y)
instance Walkable Inline Inline where
walkM :: (Inline -> m Inline) -> Inline -> m Inline
walkM Inline -> m Inline
f Inline
x = (Inline -> m 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 Inline -> m Inline
f Inline
x m Inline -> (Inline -> m Inline) -> m Inline
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Inline -> m Inline
f
query :: (Inline -> c) -> Inline -> c
query Inline -> c
f Inline
x = Inline -> c
f Inline
x c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (Inline -> c) -> Inline -> c
forall a c.
(Walkable a Citation, Walkable a [Block], Walkable a [Inline],
Monoid c) =>
(a -> c) -> Inline -> c
queryInline Inline -> c
f Inline
x
instance OVERLAPS
Walkable [Inline] [Inline] where
walkM :: ([Inline] -> m [Inline]) -> [Inline] -> m [Inline]
walkM [Inline] -> m [Inline]
f = (Inline -> m Inline) -> [Inline] -> m [Inline]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
T.traverse (([Inline] -> m [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 [Inline] -> m [Inline]
f) ([Inline] -> m [Inline])
-> ([Inline] -> m [Inline]) -> [Inline] -> m [Inline]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> [Inline] -> m [Inline]
f
query :: ([Inline] -> c) -> [Inline] -> c
query [Inline] -> c
f [Inline]
inlns = [Inline] -> c
f [Inline]
inlns c -> c -> c
forall a. Semigroup a => a -> a -> a
<> [c] -> c
forall a. Monoid a => [a] -> a
mconcat ((Inline -> c) -> [Inline] -> [c]
forall a b. (a -> b) -> [a] -> [b]
map (([Inline] -> c) -> Inline -> c
forall a c.
(Walkable a Citation, Walkable a [Block], Walkable a [Inline],
Monoid c) =>
(a -> c) -> Inline -> c
queryInline [Inline] -> c
f) [Inline]
inlns)
instance Walkable [Inline] Inline where
walkM :: ([Inline] -> m [Inline]) -> Inline -> m Inline
walkM = ([Inline] -> m [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 :: ([Inline] -> c) -> Inline -> c
query = ([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 Inline Block where
walkM :: (Inline -> m Inline) -> Block -> m Block
walkM = (Inline -> m 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 :: (Inline -> c) -> Block -> c
query = (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 [Inline] Block where
walkM :: ([Inline] -> m [Inline]) -> Block -> m Block
walkM = ([Inline] -> m [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 :: ([Inline] -> c) -> Block -> c
query = ([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 Block Block where
walkM :: (Block -> m Block) -> Block -> m Block
walkM Block -> m Block
f Block
x = (Block -> m 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 Block -> m Block
f Block
x m Block -> (Block -> m Block) -> m Block
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Block -> m Block
f
query :: (Block -> c) -> Block -> c
query Block -> c
f Block
x = Block -> c
f Block
x c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (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 Block -> c
f Block
x
instance Walkable [Block] Block where
walkM :: ([Block] -> m [Block]) -> Block -> m Block
walkM = ([Block] -> m [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 :: ([Block] -> c) -> Block -> c
query = ([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 OVERLAPS
Walkable [Block] [Block] where
walkM :: ([Block] -> m [Block]) -> [Block] -> m [Block]
walkM [Block] -> m [Block]
f = (Block -> m Block) -> [Block] -> m [Block]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
T.traverse (([Block] -> m [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 [Block] -> m [Block]
f) ([Block] -> m [Block])
-> ([Block] -> m [Block]) -> [Block] -> m [Block]
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> [Block] -> m [Block]
f
query :: ([Block] -> c) -> [Block] -> c
query [Block] -> c
f [Block]
blks = [Block] -> c
f [Block]
blks c -> c -> c
forall a. Semigroup a => a -> a -> a
<> [c] -> c
forall a. Monoid a => [a] -> a
mconcat ((Block -> c) -> [Block] -> [c]
forall a b. (a -> b) -> [a] -> [b]
map (([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 [Block] -> c
f) [Block]
blks)
instance Walkable Block Inline where
walkM :: (Block -> m Block) -> Inline -> m Inline
walkM = (Block -> m 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 :: (Block -> c) -> Inline -> c
query = (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 [Block] Inline where
walkM :: ([Block] -> m [Block]) -> Inline -> m Inline
walkM = ([Block] -> m [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 :: ([Block] -> c) -> Inline -> c
query = ([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 Block Pandoc where
walkM :: (Block -> m Block) -> Pandoc -> m Pandoc
walkM = (Block -> m 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 :: (Block -> c) -> Pandoc -> c
query = (Block -> c) -> Pandoc -> c
forall a c.
(Walkable a Meta, Walkable a [Block], Monoid c) =>
(a -> c) -> Pandoc -> c
queryPandoc
instance Walkable [Block] Pandoc where
walkM :: ([Block] -> m [Block]) -> Pandoc -> m Pandoc
walkM = ([Block] -> m [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 :: ([Block] -> c) -> Pandoc -> c
query = ([Block] -> c) -> Pandoc -> c
forall a c.
(Walkable a Meta, Walkable a [Block], Monoid c) =>
(a -> c) -> Pandoc -> c
queryPandoc
instance Walkable Inline Pandoc where
walkM :: (Inline -> m Inline) -> Pandoc -> m Pandoc
walkM = (Inline -> m 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 :: (Inline -> c) -> Pandoc -> c
query = (Inline -> c) -> Pandoc -> c
forall a c.
(Walkable a Meta, Walkable a [Block], Monoid c) =>
(a -> c) -> Pandoc -> c
queryPandoc
instance Walkable [Inline] Pandoc where
walkM :: ([Inline] -> m [Inline]) -> Pandoc -> m Pandoc
walkM = ([Inline] -> m [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 :: ([Inline] -> c) -> Pandoc -> c
query = ([Inline] -> c) -> Pandoc -> c
forall a c.
(Walkable a Meta, Walkable a [Block], Monoid c) =>
(a -> c) -> Pandoc -> c
queryPandoc
instance Walkable Meta Pandoc where
walkM :: (Meta -> m Meta) -> Pandoc -> m Pandoc
walkM Meta -> m Meta
f (Pandoc Meta
m [Block]
bs) = Meta -> [Block] -> Pandoc
Pandoc (Meta -> [Block] -> Pandoc) -> m Meta -> m ([Block] -> Pandoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Meta -> m Meta
f Meta
m m ([Block] -> Pandoc) -> m [Block] -> m Pandoc
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Block] -> m [Block]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Block]
bs
query :: (Meta -> c) -> Pandoc -> c
query Meta -> c
f (Pandoc Meta
m [Block]
_) = Meta -> c
f Meta
m
instance Walkable MetaValue Pandoc where
walkM :: (MetaValue -> m MetaValue) -> Pandoc -> m Pandoc
walkM MetaValue -> m MetaValue
f (Pandoc Meta
m [Block]
bs) = Meta -> [Block] -> Pandoc
Pandoc (Meta -> [Block] -> Pandoc) -> m Meta -> m ([Block] -> Pandoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MetaValue -> m MetaValue) -> Meta -> m Meta
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM MetaValue -> m MetaValue
f Meta
m m ([Block] -> Pandoc) -> m [Block] -> m Pandoc
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Block] -> m [Block]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Block]
bs
query :: (MetaValue -> c) -> Pandoc -> c
query MetaValue -> c
f (Pandoc Meta
m [Block]
_) = (MetaValue -> c) -> Meta -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query MetaValue -> c
f Meta
m
instance Walkable Pandoc Pandoc where
walkM :: (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
walkM Pandoc -> m Pandoc
f = Pandoc -> m Pandoc
f
query :: (Pandoc -> c) -> Pandoc -> c
query Pandoc -> c
f = Pandoc -> c
f
instance Walkable Meta Meta where
walkM :: (Meta -> m Meta) -> Meta -> m Meta
walkM Meta -> m Meta
f = Meta -> m Meta
f
query :: (Meta -> c) -> Meta -> c
query Meta -> c
f = Meta -> c
f
instance Walkable Inline Meta where
walkM :: (Inline -> m Inline) -> Meta -> m Meta
walkM Inline -> m 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
<$> (Inline -> m 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
walkM Inline -> m Inline
f Map Text MetaValue
metamap
query :: (Inline -> c) -> Meta -> c
query Inline -> c
f (Meta Map Text MetaValue
metamap) = (Inline -> c) -> Map Text MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query Inline -> c
f Map Text MetaValue
metamap
instance Walkable [Inline] Meta where
walkM :: ([Inline] -> m [Inline]) -> Meta -> m Meta
walkM [Inline] -> m [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
<$> ([Inline] -> m [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
walkM [Inline] -> m [Inline]
f Map Text MetaValue
metamap
query :: ([Inline] -> c) -> Meta -> c
query [Inline] -> c
f (Meta Map Text MetaValue
metamap) = ([Inline] -> c) -> Map Text MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query [Inline] -> c
f Map Text MetaValue
metamap
instance Walkable Block Meta where
walkM :: (Block -> m Block) -> Meta -> m Meta
walkM Block -> m 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
<$> (Block -> m 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
walkM Block -> m Block
f Map Text MetaValue
metamap
query :: (Block -> c) -> Meta -> c
query Block -> c
f (Meta Map Text MetaValue
metamap) = (Block -> c) -> Map Text MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query Block -> c
f Map Text MetaValue
metamap
instance Walkable [Block] Meta where
walkM :: ([Block] -> m [Block]) -> Meta -> m Meta
walkM [Block] -> m [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
<$> ([Block] -> m [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
walkM [Block] -> m [Block]
f Map Text MetaValue
metamap
query :: ([Block] -> c) -> Meta -> c
query [Block] -> c
f (Meta Map Text MetaValue
metamap) = ([Block] -> c) -> Map Text MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query [Block] -> c
f Map Text MetaValue
metamap
instance Walkable MetaValue Meta where
walkM :: (MetaValue -> m MetaValue) -> Meta -> m Meta
walkM MetaValue -> m MetaValue
f (Meta Map Text MetaValue
metamap) =
Map Text MetaValue -> Meta
Meta (Map Text MetaValue -> Meta)
-> ([(Text, MetaValue)] -> Map Text MetaValue)
-> [(Text, MetaValue)]
-> Meta
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Text, MetaValue)] -> Map Text MetaValue
forall k a. Eq k => [(k, a)] -> Map k a
M.fromAscList ([(Text, MetaValue)] -> Meta) -> m [(Text, MetaValue)] -> m Meta
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Text, MetaValue) -> m (Text, MetaValue))
-> [(Text, MetaValue)] -> m [(Text, MetaValue)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (\(Text
k, MetaValue
v) -> (,) Text
k (MetaValue -> (Text, MetaValue))
-> m MetaValue -> m (Text, MetaValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MetaValue -> m MetaValue) -> MetaValue -> m MetaValue
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM MetaValue -> m MetaValue
f MetaValue
v) (Map Text MetaValue -> [(Text, MetaValue)]
forall k a. Map k a -> [(k, a)]
M.toAscList Map Text MetaValue
metamap)
query :: (MetaValue -> c) -> Meta -> c
query MetaValue -> c
f (Meta Map Text MetaValue
metamap) = (Text -> MetaValue -> c) -> Map Text MetaValue -> c
forall m k a. Monoid m => (k -> a -> m) -> Map k a -> m
M.foldMapWithKey ((MetaValue -> c) -> Text -> MetaValue -> c
forall a b. a -> b -> a
const ((MetaValue -> c) -> Text -> MetaValue -> c)
-> (MetaValue -> c) -> Text -> MetaValue -> c
forall a b. (a -> b) -> a -> b
$ (MetaValue -> c) -> MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query MetaValue -> c
f) Map Text MetaValue
metamap
instance Walkable MetaValue MetaValue where
walkM :: (MetaValue -> m MetaValue) -> MetaValue -> m MetaValue
walkM MetaValue -> m MetaValue
f MetaValue
x = (MetaValue -> m MetaValue) -> MetaValue -> m MetaValue
forall (m :: * -> *).
(Monad m, Applicative m, Functor m) =>
(MetaValue -> m MetaValue) -> MetaValue -> m MetaValue
walkMetaValueM' MetaValue -> m MetaValue
f MetaValue
x m MetaValue -> (MetaValue -> m MetaValue) -> m MetaValue
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MetaValue -> m MetaValue
f
query :: (MetaValue -> c) -> MetaValue -> c
query MetaValue -> c
f MetaValue
x = MetaValue -> c
f MetaValue
x c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (MetaValue -> c) -> MetaValue -> c
forall c. Monoid c => (MetaValue -> c) -> MetaValue -> c
queryMetaValue' MetaValue -> c
f MetaValue
x
instance Walkable Inline MetaValue where
walkM :: (Inline -> m Inline) -> MetaValue -> m MetaValue
walkM = (Inline -> m 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 :: (Inline -> c) -> MetaValue -> c
query = (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 [Inline] MetaValue where
walkM :: ([Inline] -> m [Inline]) -> MetaValue -> m MetaValue
walkM = ([Inline] -> m [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 :: ([Inline] -> c) -> MetaValue -> c
query = ([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 Block MetaValue where
walkM :: (Block -> m Block) -> MetaValue -> m MetaValue
walkM = (Block -> m 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 :: (Block -> c) -> MetaValue -> c
query = (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 [Block] MetaValue where
walkM :: ([Block] -> m [Block]) -> MetaValue -> m MetaValue
walkM = ([Block] -> m [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 :: ([Block] -> c) -> MetaValue -> c
query = ([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 Inline Row where
walkM :: (Inline -> m Inline) -> Row -> m Row
walkM = (Inline -> m Inline) -> Row -> m Row
forall a (m :: * -> *).
(Walkable a Cell, Monad m) =>
(a -> m a) -> Row -> m Row
walkRowM
query :: (Inline -> c) -> Row -> c
query = (Inline -> c) -> Row -> c
forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
queryRow
instance Walkable [Inline] Row where
walkM :: ([Inline] -> m [Inline]) -> Row -> m Row
walkM = ([Inline] -> m [Inline]) -> Row -> m Row
forall a (m :: * -> *).
(Walkable a Cell, Monad m) =>
(a -> m a) -> Row -> m Row
walkRowM
query :: ([Inline] -> c) -> Row -> c
query = ([Inline] -> c) -> Row -> c
forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
queryRow
instance Walkable Block Row where
walkM :: (Block -> m Block) -> Row -> m Row
walkM = (Block -> m Block) -> Row -> m Row
forall a (m :: * -> *).
(Walkable a Cell, Monad m) =>
(a -> m a) -> Row -> m Row
walkRowM
query :: (Block -> c) -> Row -> c
query = (Block -> c) -> Row -> c
forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
queryRow
instance Walkable [Block] Row where
walkM :: ([Block] -> m [Block]) -> Row -> m Row
walkM = ([Block] -> m [Block]) -> Row -> m Row
forall a (m :: * -> *).
(Walkable a Cell, Monad m) =>
(a -> m a) -> Row -> m Row
walkRowM
query :: ([Block] -> c) -> Row -> c
query = ([Block] -> c) -> Row -> c
forall a c. (Walkable a Cell, Monoid c) => (a -> c) -> Row -> c
queryRow
instance Walkable Inline TableHead where
walkM :: (Inline -> m Inline) -> TableHead -> m TableHead
walkM = (Inline -> m Inline) -> TableHead -> m TableHead
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableHead -> m TableHead
walkTableHeadM
query :: (Inline -> c) -> TableHead -> c
query = (Inline -> c) -> TableHead -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableHead -> c
queryTableHead
instance Walkable [Inline] TableHead where
walkM :: ([Inline] -> m [Inline]) -> TableHead -> m TableHead
walkM = ([Inline] -> m [Inline]) -> TableHead -> m TableHead
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableHead -> m TableHead
walkTableHeadM
query :: ([Inline] -> c) -> TableHead -> c
query = ([Inline] -> c) -> TableHead -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableHead -> c
queryTableHead
instance Walkable Block TableHead where
walkM :: (Block -> m Block) -> TableHead -> m TableHead
walkM = (Block -> m Block) -> TableHead -> m TableHead
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableHead -> m TableHead
walkTableHeadM
query :: (Block -> c) -> TableHead -> c
query = (Block -> c) -> TableHead -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableHead -> c
queryTableHead
instance Walkable [Block] TableHead where
walkM :: ([Block] -> m [Block]) -> TableHead -> m TableHead
walkM = ([Block] -> m [Block]) -> TableHead -> m TableHead
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableHead -> m TableHead
walkTableHeadM
query :: ([Block] -> c) -> TableHead -> c
query = ([Block] -> c) -> TableHead -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableHead -> c
queryTableHead
instance Walkable Inline TableBody where
walkM :: (Inline -> m Inline) -> TableBody -> m TableBody
walkM = (Inline -> m Inline) -> TableBody -> m TableBody
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableBody -> m TableBody
walkTableBodyM
query :: (Inline -> c) -> TableBody -> c
query = (Inline -> c) -> TableBody -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableBody -> c
queryTableBody
instance Walkable [Inline] TableBody where
walkM :: ([Inline] -> m [Inline]) -> TableBody -> m TableBody
walkM = ([Inline] -> m [Inline]) -> TableBody -> m TableBody
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableBody -> m TableBody
walkTableBodyM
query :: ([Inline] -> c) -> TableBody -> c
query = ([Inline] -> c) -> TableBody -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableBody -> c
queryTableBody
instance Walkable Block TableBody where
walkM :: (Block -> m Block) -> TableBody -> m TableBody
walkM = (Block -> m Block) -> TableBody -> m TableBody
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableBody -> m TableBody
walkTableBodyM
query :: (Block -> c) -> TableBody -> c
query = (Block -> c) -> TableBody -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableBody -> c
queryTableBody
instance Walkable [Block] TableBody where
walkM :: ([Block] -> m [Block]) -> TableBody -> m TableBody
walkM = ([Block] -> m [Block]) -> TableBody -> m TableBody
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableBody -> m TableBody
walkTableBodyM
query :: ([Block] -> c) -> TableBody -> c
query = ([Block] -> c) -> TableBody -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableBody -> c
queryTableBody
instance Walkable Inline TableFoot where
walkM :: (Inline -> m Inline) -> TableFoot -> m TableFoot
walkM = (Inline -> m Inline) -> TableFoot -> m TableFoot
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableFoot -> m TableFoot
walkTableFootM
query :: (Inline -> c) -> TableFoot -> c
query = (Inline -> c) -> TableFoot -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableFoot -> c
queryTableFoot
instance Walkable [Inline] TableFoot where
walkM :: ([Inline] -> m [Inline]) -> TableFoot -> m TableFoot
walkM = ([Inline] -> m [Inline]) -> TableFoot -> m TableFoot
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableFoot -> m TableFoot
walkTableFootM
query :: ([Inline] -> c) -> TableFoot -> c
query = ([Inline] -> c) -> TableFoot -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableFoot -> c
queryTableFoot
instance Walkable Block TableFoot where
walkM :: (Block -> m Block) -> TableFoot -> m TableFoot
walkM = (Block -> m Block) -> TableFoot -> m TableFoot
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableFoot -> m TableFoot
walkTableFootM
query :: (Block -> c) -> TableFoot -> c
query = (Block -> c) -> TableFoot -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableFoot -> c
queryTableFoot
instance Walkable [Block] TableFoot where
walkM :: ([Block] -> m [Block]) -> TableFoot -> m TableFoot
walkM = ([Block] -> m [Block]) -> TableFoot -> m TableFoot
forall a (m :: * -> *).
(Walkable a Row, Monad m) =>
(a -> m a) -> TableFoot -> m TableFoot
walkTableFootM
query :: ([Block] -> c) -> TableFoot -> c
query = ([Block] -> c) -> TableFoot -> c
forall a c.
(Walkable a Row, Monoid c) =>
(a -> c) -> TableFoot -> c
queryTableFoot
instance Walkable Inline Caption where
walkM :: (Inline -> m Inline) -> Caption -> m Caption
walkM = (Inline -> m 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 :: (Inline -> c) -> Caption -> c
query = (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 [Inline] Caption where
walkM :: ([Inline] -> m [Inline]) -> Caption -> m Caption
walkM = ([Inline] -> m [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 :: ([Inline] -> c) -> Caption -> c
query = ([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 Block Caption where
walkM :: (Block -> m Block) -> Caption -> m Caption
walkM = (Block -> m 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 :: (Block -> c) -> Caption -> c
query = (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 [Block] Caption where
walkM :: ([Block] -> m [Block]) -> Caption -> m Caption
walkM = ([Block] -> m [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 :: ([Block] -> c) -> Caption -> c
query = ([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 Inline Cell where
walkM :: (Inline -> m Inline) -> Cell -> m Cell
walkM = (Inline -> m Inline) -> Cell -> m Cell
forall a (m :: * -> *).
(Walkable a [Block], Monad m) =>
(a -> m a) -> Cell -> m Cell
walkCellM
query :: (Inline -> c) -> Cell -> c
query = (Inline -> c) -> Cell -> c
forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
queryCell
instance Walkable [Inline] Cell where
walkM :: ([Inline] -> m [Inline]) -> Cell -> m Cell
walkM = ([Inline] -> m [Inline]) -> Cell -> m Cell
forall a (m :: * -> *).
(Walkable a [Block], Monad m) =>
(a -> m a) -> Cell -> m Cell
walkCellM
query :: ([Inline] -> c) -> Cell -> c
query = ([Inline] -> c) -> Cell -> c
forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
queryCell
instance Walkable Block Cell where
walkM :: (Block -> m Block) -> Cell -> m Cell
walkM = (Block -> m Block) -> Cell -> m Cell
forall a (m :: * -> *).
(Walkable a [Block], Monad m) =>
(a -> m a) -> Cell -> m Cell
walkCellM
query :: (Block -> c) -> Cell -> c
query = (Block -> c) -> Cell -> c
forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
queryCell
instance Walkable [Block] Cell where
walkM :: ([Block] -> m [Block]) -> Cell -> m Cell
walkM = ([Block] -> m [Block]) -> Cell -> m Cell
forall a (m :: * -> *).
(Walkable a [Block], Monad m) =>
(a -> m a) -> Cell -> m Cell
walkCellM
query :: ([Block] -> c) -> Cell -> c
query = ([Block] -> c) -> Cell -> c
forall a c. (Walkable a [Block], Monoid c) => (a -> c) -> Cell -> c
queryCell
instance Walkable Inline Citation where
walkM :: (Inline -> m Inline) -> Citation -> m Citation
walkM = (Inline -> m Inline) -> Citation -> m Citation
forall a (m :: * -> *).
(Walkable a [Inline], Monad m, Applicative m, Functor m) =>
(a -> m a) -> Citation -> m Citation
walkCitationM
query :: (Inline -> c) -> Citation -> c
query = (Inline -> c) -> Citation -> c
forall a c.
(Walkable a [Inline], Monoid c) =>
(a -> c) -> Citation -> c
queryCitation
instance Walkable [Inline] Citation where
walkM :: ([Inline] -> m [Inline]) -> Citation -> m Citation
walkM = ([Inline] -> m [Inline]) -> Citation -> m Citation
forall a (m :: * -> *).
(Walkable a [Inline], Monad m, Applicative m, Functor m) =>
(a -> m a) -> Citation -> m Citation
walkCitationM
query :: ([Inline] -> c) -> Citation -> c
query = ([Inline] -> c) -> Citation -> c
forall a c.
(Walkable a [Inline], Monoid c) =>
(a -> c) -> Citation -> c
queryCitation
instance Walkable Block Citation where
walkM :: (Block -> m Block) -> Citation -> m Citation
walkM = (Block -> m Block) -> Citation -> m Citation
forall a (m :: * -> *).
(Walkable a [Inline], Monad m, Applicative m, Functor m) =>
(a -> m a) -> Citation -> m Citation
walkCitationM
query :: (Block -> c) -> Citation -> c
query = (Block -> c) -> Citation -> c
forall a c.
(Walkable a [Inline], Monoid c) =>
(a -> c) -> Citation -> c
queryCitation
instance Walkable [Block] Citation where
walkM :: ([Block] -> m [Block]) -> Citation -> m Citation
walkM = ([Block] -> m [Block]) -> Citation -> m Citation
forall a (m :: * -> *).
(Walkable a [Inline], Monad m, Applicative m, Functor m) =>
(a -> m a) -> Citation -> m Citation
walkCitationM
query :: ([Block] -> c) -> Citation -> c
query = ([Block] -> c) -> Citation -> c
forall a c.
(Walkable a [Inline], Monoid c) =>
(a -> c) -> Citation -> c
queryCitation
walkInlineM :: (Walkable a Citation, Walkable a [Block],
Walkable a [Inline], Monad m, Applicative m, Functor m)
=> (a -> m a) -> Inline -> m Inline
walkInlineM :: (a -> m a) -> Inline -> m Inline
walkInlineM a -> m a
_ (Str Text
xs) = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inline
Str Text
xs)
walkInlineM a -> m a
f (Emph [Inline]
xs) = [Inline] -> Inline
Emph ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Underline [Inline]
xs) = [Inline] -> Inline
Underline ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Strong [Inline]
xs) = [Inline] -> Inline
Strong ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Strikeout [Inline]
xs) = [Inline] -> Inline
Strikeout ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Subscript [Inline]
xs) = [Inline] -> Inline
Subscript ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Superscript [Inline]
xs) = [Inline] -> Inline
Superscript ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (SmallCaps [Inline]
xs) = [Inline] -> Inline
SmallCaps ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Quoted QuoteType
qt [Inline]
xs) = QuoteType -> [Inline] -> Inline
Quoted QuoteType
qt ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Link Attr
atr [Inline]
xs Target
t) = Attr -> [Inline] -> Target -> Inline
Link Attr
atr ([Inline] -> Target -> Inline)
-> m [Inline] -> m (Target -> Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs m (Target -> Inline) -> m Target -> m Inline
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Target -> m Target
forall (f :: * -> *) a. Applicative f => a -> f a
pure Target
t
walkInlineM a -> m a
f (Image Attr
atr [Inline]
xs Target
t) = Attr -> [Inline] -> Target -> Inline
Image Attr
atr ([Inline] -> Target -> Inline)
-> m [Inline] -> m (Target -> Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs m (Target -> Inline) -> m Target -> m Inline
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Target -> m Target
forall (f :: * -> *) a. Applicative f => a -> f a
pure Target
t
walkInlineM a -> m a
f (Note [Block]
bs) = [Block] -> Inline
Note ([Block] -> Inline) -> m [Block] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
bs
walkInlineM a -> m a
f (Span Attr
attr [Inline]
xs) = Attr -> [Inline] -> Inline
Span Attr
attr ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
f (Cite [Citation]
cs [Inline]
xs) = [Citation] -> [Inline] -> Inline
Cite ([Citation] -> [Inline] -> Inline)
-> m [Citation] -> m ([Inline] -> Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Citation] -> m [Citation]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Citation]
cs m ([Inline] -> Inline) -> m [Inline] -> m Inline
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkInlineM a -> m a
_ Inline
LineBreak = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
LineBreak
walkInlineM a -> m a
_ Inline
SoftBreak = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
SoftBreak
walkInlineM a -> m a
_ Inline
Space = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
Space
walkInlineM a -> m a
_ x :: Inline
x@Code {} = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
x
walkInlineM a -> m a
_ x :: Inline
x@Math {} = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
x
walkInlineM a -> m a
_ x :: Inline
x@RawInline {} = Inline -> m Inline
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
x
queryInline :: (Walkable a Citation, Walkable a [Block],
Walkable a [Inline], Monoid c)
=> (a -> c) -> Inline -> c
queryInline :: (a -> c) -> Inline -> c
queryInline a -> c
_ (Str Text
_) = c
forall a. Monoid a => a
mempty
queryInline a -> c
f (Emph [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Underline [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Strong [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Strikeout [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Subscript [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Superscript [Inline]
xs)= (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (SmallCaps [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Quoted QuoteType
_ [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Cite [Citation]
cs [Inline]
xs) = (a -> c) -> [Citation] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Citation]
cs c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
_ (Code Attr
_ Text
_) = c
forall a. Monoid a => a
mempty
queryInline a -> c
_ Inline
Space = c
forall a. Monoid a => a
mempty
queryInline a -> c
_ Inline
SoftBreak = c
forall a. Monoid a => a
mempty
queryInline a -> c
_ Inline
LineBreak = c
forall a. Monoid a => a
mempty
queryInline a -> c
_ (Math MathType
_ Text
_) = c
forall a. Monoid a => a
mempty
queryInline a -> c
_ (RawInline Format
_ Text
_) = c
forall a. Monoid a => a
mempty
queryInline a -> c
f (Link Attr
_ [Inline]
xs Target
_) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Image Attr
_ [Inline]
xs Target
_) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryInline a -> c
f (Note [Block]
bs) = (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
bs
queryInline a -> c
f (Span Attr
_ [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
walkBlockM :: (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 :: (a -> m a) -> Block -> m Block
walkBlockM a -> m a
f (Para [Inline]
xs) = [Inline] -> Block
Para ([Inline] -> Block) -> m [Inline] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkBlockM a -> m a
f (Plain [Inline]
xs) = [Inline] -> Block
Plain ([Inline] -> Block) -> m [Inline] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkBlockM a -> m a
f (LineBlock [[Inline]]
xs) = [[Inline]] -> Block
LineBlock ([[Inline]] -> Block) -> m [[Inline]] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [[Inline]] -> m [[Inline]]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [[Inline]]
xs
walkBlockM a -> m a
f (BlockQuote [Block]
xs) = [Block] -> Block
BlockQuote ([Block] -> Block) -> m [Block] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
xs
walkBlockM a -> m a
f (OrderedList ListAttributes
a [[Block]]
cs) = ListAttributes -> [[Block]] -> Block
OrderedList ListAttributes
a ([[Block]] -> Block) -> m [[Block]] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [[Block]] -> m [[Block]]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [[Block]]
cs
walkBlockM a -> m a
f (BulletList [[Block]]
cs) = [[Block]] -> Block
BulletList ([[Block]] -> Block) -> m [[Block]] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [[Block]] -> m [[Block]]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [[Block]]
cs
walkBlockM a -> m a
f (DefinitionList [([Inline], [[Block]])]
xs) = [([Inline], [[Block]])] -> Block
DefinitionList ([([Inline], [[Block]])] -> Block)
-> m [([Inline], [[Block]])] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [([Inline], [[Block]])] -> m [([Inline], [[Block]])]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [([Inline], [[Block]])]
xs
walkBlockM a -> m a
f (Header Int
lev Attr
attr [Inline]
xs) = Int -> Attr -> [Inline] -> Block
Header Int
lev Attr
attr ([Inline] -> Block) -> m [Inline] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
xs
walkBlockM a -> m a
f (Div Attr
attr [Block]
bs') = Attr -> [Block] -> Block
Div Attr
attr ([Block] -> Block) -> m [Block] -> m Block
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
bs'
walkBlockM a -> m a
_ x :: Block
x@CodeBlock {} = Block -> m Block
forall (m :: * -> *) a. Monad m => a -> m a
return Block
x
walkBlockM a -> m a
_ x :: Block
x@RawBlock {} = Block -> m Block
forall (m :: * -> *) a. Monad m => a -> m a
return Block
x
walkBlockM a -> m a
_ Block
HorizontalRule = Block -> m Block
forall (m :: * -> *) a. Monad m => a -> m a
return Block
HorizontalRule
walkBlockM a -> m a
_ Block
Null = Block -> m Block
forall (m :: * -> *) a. Monad m => a -> m a
return Block
Null
walkBlockM a -> m a
f (Table Attr
attr Caption
capt [ColSpec]
as TableHead
hs [TableBody]
bs TableFoot
fs)
= do Caption
capt' <- (a -> m a) -> Caption -> m Caption
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f Caption
capt
TableHead
hs' <- (a -> m a) -> TableHead -> m TableHead
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f TableHead
hs
[TableBody]
bs' <- (a -> m a) -> [TableBody] -> m [TableBody]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [TableBody]
bs
TableFoot
fs' <- (a -> m a) -> TableFoot -> m TableFoot
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f TableFoot
fs
Block -> m Block
forall (m :: * -> *) a. Monad m => a -> m a
return (Block -> m Block) -> Block -> m Block
forall a b. (a -> b) -> a -> b
$ Attr
-> Caption
-> [ColSpec]
-> TableHead
-> [TableBody]
-> TableFoot
-> Block
Table Attr
attr Caption
capt' [ColSpec]
as TableHead
hs' [TableBody]
bs' TableFoot
fs'
queryBlock :: (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 :: (a -> c) -> Block -> c
queryBlock a -> c
f (Para [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryBlock a -> c
f (Plain [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryBlock a -> c
f (LineBlock [[Inline]]
xs) = (a -> c) -> [[Inline]] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [[Inline]]
xs
queryBlock a -> c
_ (CodeBlock Attr
_ Text
_) = c
forall a. Monoid a => a
mempty
queryBlock a -> c
_ (RawBlock Format
_ Text
_) = c
forall a. Monoid a => a
mempty
queryBlock a -> c
f (BlockQuote [Block]
bs) = (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
bs
queryBlock a -> c
f (OrderedList ListAttributes
_ [[Block]]
cs) = (a -> c) -> [[Block]] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [[Block]]
cs
queryBlock a -> c
f (BulletList [[Block]]
cs) = (a -> c) -> [[Block]] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [[Block]]
cs
queryBlock a -> c
f (DefinitionList [([Inline], [[Block]])]
xs) = (a -> c) -> [([Inline], [[Block]])] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [([Inline], [[Block]])]
xs
queryBlock a -> c
f (Header Int
_ Attr
_ [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryBlock a -> c
_ Block
HorizontalRule = c
forall a. Monoid a => a
mempty
queryBlock a -> c
f (Table Attr
_ Caption
capt [ColSpec]
_ TableHead
hs [TableBody]
bs TableFoot
fs)
= (a -> c) -> Caption -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f Caption
capt c -> c -> c
forall a. Semigroup a => a -> a -> a
<>
(a -> c) -> TableHead -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f TableHead
hs c -> c -> c
forall a. Semigroup a => a -> a -> a
<>
(a -> c) -> [TableBody] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [TableBody]
bs c -> c -> c
forall a. Semigroup a => a -> a -> a
<>
(a -> c) -> TableFoot -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f TableFoot
fs
queryBlock a -> c
f (Div Attr
_ [Block]
bs) = (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
bs
queryBlock a -> c
_ Block
Null = c
forall a. Monoid a => a
mempty
walkMetaValueM :: (Walkable a MetaValue, Walkable a [Block],
Walkable a [Inline], Monad f, Applicative f, Functor f)
=> (a -> f a) -> MetaValue -> f MetaValue
walkMetaValueM :: (a -> f a) -> MetaValue -> f MetaValue
walkMetaValueM a -> f a
f (MetaList [MetaValue]
xs) = [MetaValue] -> MetaValue
MetaList ([MetaValue] -> MetaValue) -> f [MetaValue] -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> [MetaValue] -> f [MetaValue]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> f a
f [MetaValue]
xs
walkMetaValueM a -> f a
_ (MetaBool Bool
b) = MetaValue -> f MetaValue
forall (m :: * -> *) a. Monad m => a -> m a
return (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
forall a b. (a -> b) -> a -> b
$ Bool -> MetaValue
MetaBool Bool
b
walkMetaValueM a -> f a
_ (MetaString Text
s) = MetaValue -> f MetaValue
forall (m :: * -> *) a. Monad m => a -> m a
return (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
forall a b. (a -> b) -> a -> b
$ Text -> MetaValue
MetaString Text
s
walkMetaValueM a -> f a
f (MetaInlines [Inline]
xs) = [Inline] -> MetaValue
MetaInlines ([Inline] -> MetaValue) -> f [Inline] -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> [Inline] -> f [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> f a
f [Inline]
xs
walkMetaValueM a -> f a
f (MetaBlocks [Block]
bs) = [Block] -> MetaValue
MetaBlocks ([Block] -> MetaValue) -> f [Block] -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> [Block] -> f [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> f a
f [Block]
bs
walkMetaValueM a -> f a
f (MetaMap Map Text MetaValue
m) = Map Text MetaValue -> MetaValue
MetaMap (Map Text MetaValue -> MetaValue)
-> f (Map Text MetaValue) -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> Map Text MetaValue -> f (Map Text MetaValue)
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> f a
f Map Text MetaValue
m
walkMetaValueM' :: (Monad f, Applicative f, Functor f)
=> (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
walkMetaValueM' :: (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
walkMetaValueM' MetaValue -> f MetaValue
f (MetaMap Map Text MetaValue
m) =
Map Text MetaValue -> MetaValue
MetaMap (Map Text MetaValue -> MetaValue)
-> ([(Text, MetaValue)] -> Map Text MetaValue)
-> [(Text, MetaValue)]
-> MetaValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Text, MetaValue)] -> Map Text MetaValue
forall k a. Eq k => [(k, a)] -> Map k a
M.fromAscList ([(Text, MetaValue)] -> MetaValue)
-> f [(Text, MetaValue)] -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Text, MetaValue) -> f (Text, MetaValue))
-> [(Text, MetaValue)] -> f [(Text, MetaValue)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (\(Text
k, MetaValue
v) -> (,) Text
k (MetaValue -> (Text, MetaValue))
-> f MetaValue -> f (Text, MetaValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM MetaValue -> f MetaValue
f MetaValue
v) (Map Text MetaValue -> [(Text, MetaValue)]
forall k a. Map k a -> [(k, a)]
M.toAscList Map Text MetaValue
m)
walkMetaValueM' MetaValue -> f MetaValue
f (MetaList [MetaValue]
xs) = [MetaValue] -> MetaValue
MetaList ([MetaValue] -> MetaValue) -> f [MetaValue] -> f MetaValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MetaValue -> f MetaValue) -> [MetaValue] -> f [MetaValue]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((MetaValue -> f MetaValue) -> MetaValue -> f MetaValue
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM MetaValue -> f MetaValue
f) [MetaValue]
xs
walkMetaValueM' MetaValue -> f MetaValue
_ MetaValue
x = MetaValue -> f MetaValue
forall (m :: * -> *) a. Monad m => a -> m a
return MetaValue
x
queryMetaValue :: (Walkable a MetaValue, Walkable a [Block],
Walkable a [Inline], Monoid c)
=> (a -> c) -> MetaValue -> c
queryMetaValue :: (a -> c) -> MetaValue -> c
queryMetaValue a -> c
f (MetaList [MetaValue]
xs) = (a -> c) -> [MetaValue] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [MetaValue]
xs
queryMetaValue a -> c
_ (MetaBool Bool
_) = c
forall a. Monoid a => a
mempty
queryMetaValue a -> c
_ (MetaString Text
_) = c
forall a. Monoid a => a
mempty
queryMetaValue a -> c
f (MetaInlines [Inline]
xs) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
xs
queryMetaValue a -> c
f (MetaBlocks [Block]
bs) = (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
bs
queryMetaValue a -> c
f (MetaMap Map Text MetaValue
m) = (a -> c) -> Map Text MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f Map Text MetaValue
m
queryMetaValue' :: Monoid c
=> (MetaValue -> c) -> MetaValue -> c
queryMetaValue' :: (MetaValue -> c) -> MetaValue -> c
queryMetaValue' MetaValue -> c
f (MetaMap Map Text MetaValue
m) = (Text -> MetaValue -> c) -> Map Text MetaValue -> c
forall m k a. Monoid m => (k -> a -> m) -> Map k a -> m
M.foldMapWithKey ((MetaValue -> c) -> Text -> MetaValue -> c
forall a b. a -> b -> a
const ((MetaValue -> c) -> Text -> MetaValue -> c)
-> (MetaValue -> c) -> Text -> MetaValue -> c
forall a b. (a -> b) -> a -> b
$ (MetaValue -> c) -> MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query MetaValue -> c
f) Map Text MetaValue
m
queryMetaValue' MetaValue -> c
f (MetaList [MetaValue]
xs) = [c] -> c
forall a. Monoid a => [a] -> a
mconcat ([c] -> c) -> [c] -> c
forall a b. (a -> b) -> a -> b
$ (MetaValue -> c) -> [MetaValue] -> [c]
forall a b. (a -> b) -> [a] -> [b]
map ((MetaValue -> c) -> MetaValue -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query MetaValue -> c
f) [MetaValue]
xs
queryMetaValue' MetaValue -> c
_ MetaValue
_ = c
forall a. Monoid a => a
mempty
walkCitationM :: (Walkable a [Inline], Monad m, Applicative m, Functor m)
=> (a -> m a) -> Citation -> m Citation
walkCitationM :: (a -> m a) -> Citation -> m Citation
walkCitationM a -> m a
f (Citation Text
id' [Inline]
pref [Inline]
suff CitationMode
mode Int
notenum Int
hash) =
do [Inline]
pref' <- (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
pref
[Inline]
suff' <- (a -> m a) -> [Inline] -> m [Inline]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Inline]
suff
Citation -> m Citation
forall (m :: * -> *) a. Monad m => a -> m a
return (Citation -> m Citation) -> Citation -> m Citation
forall a b. (a -> b) -> a -> b
$ Text
-> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
Citation Text
id' [Inline]
pref' [Inline]
suff' CitationMode
mode Int
notenum Int
hash
queryCitation :: (Walkable a [Inline], Monoid c)
=> (a -> c) -> Citation -> c
queryCitation :: (a -> c) -> Citation -> c
queryCitation a -> c
f (Citation Text
_ [Inline]
pref [Inline]
suff CitationMode
_ Int
_ Int
_) = (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
pref c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (a -> c) -> [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Inline]
suff
walkRowM :: (Walkable a Cell, Monad m)
=> (a -> m a) -> Row -> m Row
walkRowM :: (a -> m a) -> Row -> m Row
walkRowM a -> m a
f (Row Attr
attr [Cell]
bd) = Attr -> [Cell] -> Row
Row Attr
attr ([Cell] -> Row) -> m [Cell] -> m Row
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Cell] -> m [Cell]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Cell]
bd
queryRow :: (Walkable a Cell, Monoid c)
=> (a -> c) -> Row -> c
queryRow :: (a -> c) -> Row -> c
queryRow a -> c
f (Row Attr
_ [Cell]
bd) = (a -> c) -> [Cell] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Cell]
bd
walkTableHeadM :: (Walkable a Row, Monad m)
=> (a -> m a) -> TableHead -> m TableHead
walkTableHeadM :: (a -> m a) -> TableHead -> m TableHead
walkTableHeadM a -> m a
f (TableHead Attr
attr [Row]
body) = Attr -> [Row] -> TableHead
TableHead Attr
attr ([Row] -> TableHead) -> m [Row] -> m TableHead
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Row] -> m [Row]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Row]
body
queryTableHead :: (Walkable a Row, Monoid c)
=> (a -> c) -> TableHead -> c
queryTableHead :: (a -> c) -> TableHead -> c
queryTableHead a -> c
f (TableHead Attr
_ [Row]
body) = (a -> c) -> [Row] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Row]
body
walkTableBodyM :: (Walkable a Row, Monad m)
=> (a -> m a) -> TableBody -> m TableBody
walkTableBodyM :: (a -> m a) -> TableBody -> m TableBody
walkTableBodyM a -> m a
f (TableBody Attr
attr RowHeadColumns
rhc [Row]
hd [Row]
bd) = Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
attr RowHeadColumns
rhc ([Row] -> [Row] -> TableBody) -> m [Row] -> m ([Row] -> TableBody)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Row] -> m [Row]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Row]
hd m ([Row] -> TableBody) -> m [Row] -> m TableBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> m a) -> [Row] -> m [Row]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Row]
bd
queryTableBody :: (Walkable a Row, Monoid c)
=> (a -> c) -> TableBody -> c
queryTableBody :: (a -> c) -> TableBody -> c
queryTableBody a -> c
f (TableBody Attr
_ RowHeadColumns
_ [Row]
hd [Row]
bd) = (a -> c) -> [Row] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Row]
hd c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (a -> c) -> [Row] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Row]
bd
walkTableFootM :: (Walkable a Row, Monad m)
=> (a -> m a) -> TableFoot -> m TableFoot
a -> m a
f (TableFoot Attr
attr [Row]
body) = Attr -> [Row] -> TableFoot
TableFoot Attr
attr ([Row] -> TableFoot) -> m [Row] -> m TableFoot
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Row] -> m [Row]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Row]
body
queryTableFoot :: (Walkable a Row, Monoid c)
=> (a -> c) -> TableFoot -> c
a -> c
f (TableFoot Attr
_ [Row]
body) = (a -> c) -> [Row] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Row]
body
walkCellM :: (Walkable a [Block], Monad m)
=> (a -> m a) -> Cell -> m Cell
walkCellM :: (a -> m a) -> Cell -> m Cell
walkCellM a -> m a
f (Cell Attr
attr Alignment
ma RowSpan
rs ColSpan
cs [Block]
content) = Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
ma RowSpan
rs ColSpan
cs ([Block] -> Cell) -> m [Block] -> m Cell
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
content
queryCell :: (Walkable a [Block], Monoid c)
=> (a -> c) -> Cell -> c
queryCell :: (a -> c) -> Cell -> c
queryCell a -> c
f (Cell Attr
_ Alignment
_ RowSpan
_ ColSpan
_ [Block]
content) = (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
content
walkCaptionM :: (Walkable a [Block], Walkable a [Inline], Monad m, Walkable a ShortCaption)
=> (a -> m a) -> Caption -> m Caption
walkCaptionM :: (a -> m a) -> Caption -> m Caption
walkCaptionM a -> m a
f (Caption Maybe [Inline]
mshort [Block]
body) = Maybe [Inline] -> [Block] -> Caption
Caption (Maybe [Inline] -> [Block] -> Caption)
-> m (Maybe [Inline]) -> m ([Block] -> Caption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m a) -> Maybe [Inline] -> m (Maybe [Inline])
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f Maybe [Inline]
mshort m ([Block] -> Caption) -> m [Block] -> m Caption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
body
queryCaption :: (Walkable a [Block], Walkable a [Inline], Walkable a ShortCaption, Monoid c)
=> (a -> c) -> Caption -> c
queryCaption :: (a -> c) -> Caption -> c
queryCaption a -> c
f (Caption Maybe [Inline]
mshort [Block]
body) = (a -> c) -> Maybe [Inline] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f Maybe [Inline]
mshort c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
body
walkPandocM :: (Walkable a Meta, Walkable a [Block], Monad m,
Applicative m, Functor m)
=> (a -> m a) -> Pandoc -> m Pandoc
walkPandocM :: (a -> m a) -> Pandoc -> m Pandoc
walkPandocM a -> m a
f (Pandoc Meta
m [Block]
bs) = do Meta
m' <- (a -> m a) -> Meta -> m Meta
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f Meta
m
[Block]
bs' <- (a -> m a) -> [Block] -> m [Block]
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
walkM a -> m a
f [Block]
bs
Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Meta -> [Block] -> Pandoc
Pandoc Meta
m' [Block]
bs'
queryPandoc :: (Walkable a Meta, Walkable a [Block], Monoid c)
=> (a -> c) -> Pandoc -> c
queryPandoc :: (a -> c) -> Pandoc -> c
queryPandoc a -> c
f (Pandoc Meta
m [Block]
bs) = (a -> c) -> Meta -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f Meta
m c -> c -> c
forall a. Semigroup a => a -> a -> a
<> (a -> c) -> [Block] -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query a -> c
f [Block]
bs