    {-# LANGUAGE TypeOperators #-}
    {-# LANGUAGE DefaultSignatures #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE UndecidableInstances #-}

    module AsciiDoc.Generic
      ( HasInlines(..)
      , HasBlocks(..)
      ) where

    import GHC.Generics hiding (Meta)
    import AsciiDoc.AST
    import Control.Monad

    class GHasInlines f where
      gfoldInlines :: Monoid m => (Inline -> m) -> f p -> m
      gmapInlines :: Monad m => (Inline -> m Inline) -> f p -> m (f p)

    instance GHasInlines U1 where
      gfoldInlines :: forall m p. Monoid m => (Inline -> m) -> U1 p -> m
    gfoldInlines Inline -> m
    _ U1 p
    _ = m
    forall a. Monoid a => a
    mempty
      gmapInlines :: forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> U1 p -> m (U1 p)
    gmapInlines Inline -> m Inline
    _ U1 p
    _ = U1 p -> m (U1 p)
    forall a. a -> m a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure U1 p
    forall a. Monoid a => a
    mempty

    instance (GHasInlines f, GHasInlines g) => GHasInlines (f :*: g) where
      gfoldInlines :: forall m p. Monoid m => (Inline -> m) -> (:*:) f g p -> m
    gfoldInlines Inline -> m
    f (f p
    x :*: g p
    y) = (Inline -> m) -> f p -> m
    forall m p. Monoid m => (Inline -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f f p
    x m -> m -> m
    forall a. Semigroup a => a -> a -> a
    <> (Inline -> m) -> g p -> m
    forall m p. Monoid m => (Inline -> m) -> g p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f g p
    y
      gmapInlines :: forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> (:*:) f g p -> m ((:*:) f g p)
    gmapInlines Inline -> m Inline
    f (f p
    x :*: g p
    y) = (f p -> g p -> (:*:) f g p)
    -> m (f p) -> m (g p) -> m ((:*:) f g p)
    forall (m :: * -> *) a1 a2 r.
    Monad m =>
    (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
    liftM2 f p -> g p -> (:*:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k).
    f p -> g p -> (:*:) f g p
    (:*:) ((Inline -> m Inline) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> f p -> m (f p)
    gmapInlines Inline -> m Inline
    f f p
    x) ((Inline -> m Inline) -> g p -> m (g p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> g p -> m (g p)
    gmapInlines Inline -> m Inline
    f g p
    y)

    instance (GHasInlines f, GHasInlines g) => GHasInlines (f :+: g) where
      gfoldInlines :: forall m p. Monoid m => (Inline -> m) -> (:+:) f g p -> m
    gfoldInlines Inline -> m
    f (L1 f p
    x) = (Inline -> m) -> f p -> m
    forall m p. Monoid m => (Inline -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f f p
    x
      gfoldInlines Inline -> m
    f (R1 g p
    y) = (Inline -> m) -> g p -> m
    forall m p. Monoid m => (Inline -> m) -> g p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f g p
    y
      gmapInlines :: forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> (:+:) f g p -> m ((:+:) f g p)
    gmapInlines Inline -> m Inline
    f (L1 f p
    x) = f p -> (:+:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
    L1 (f p -> (:+:) f g p) -> m (f p) -> m ((:+:) f g p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inline -> m Inline) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> f p -> m (f p)
    gmapInlines Inline -> m Inline
    f f p
    x
      gmapInlines Inline -> m Inline
    f (R1 g p
    y) = g p -> (:+:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
    R1 (g p -> (:+:) f g p) -> m (g p) -> m ((:+:) f g p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inline -> m Inline) -> g p -> m (g p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> g p -> m (g p)
    gmapInlines Inline -> m Inline
    f g p
    y

    instance GHasInlines f => GHasInlines (M1 i c f) where
      gfoldInlines :: forall m p. Monoid m => (Inline -> m) -> M1 i c f p -> m
    gfoldInlines Inline -> m
    f (M1 f p
    x) = (Inline -> m) -> f p -> m
    forall m p. Monoid m => (Inline -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f f p
    x
      gmapInlines :: forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> M1 i c f p -> m (M1 i c f p)
    gmapInlines Inline -> m Inline
    f (M1 f p
    x) = f p -> M1 i c f p
    forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
    M1 (f p -> M1 i c f p) -> m (f p) -> m (M1 i c f p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inline -> m Inline) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> f p -> m (f p)
    gmapInlines Inline -> m Inline
    f f p
    x

    class HasInlines a where
      foldInlines :: Monoid m => (Inline -> m) -> a -> m
      mapInlines :: Monad m => (Inline -> m Inline) -> a -> m a

      default foldInlines :: (Generic a, GHasInlines (Rep a), Monoid m)
                          => (Inline -> m) -> a -> m
      foldInlines Inline -> m
    f = (Inline -> m) -> Rep a (ZonkAny 0) -> m
    forall m p. Monoid m => (Inline -> m) -> Rep a p -> m
    forall (f :: * -> *) m p.
    (GHasInlines f, Monoid m) =>
    (Inline -> m) -> f p -> m
    gfoldInlines Inline -> m
    f (Rep a (ZonkAny 0) -> m) -> (a -> Rep a (ZonkAny 0)) -> a -> m
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Rep a (ZonkAny 0)
    forall x. a -> Rep a x
    forall a x. Generic a => a -> Rep a x
    from

      default mapInlines :: (Generic a, GHasInlines (Rep a), Monad m)
                          => (Inline -> m Inline) -> a -> m a
      mapInlines Inline -> m Inline
    f a
    x = Rep a (ZonkAny 1) -> a
    forall a x. Generic a => Rep a x -> a
    forall x. Rep a x -> a
    to (Rep a (ZonkAny 1) -> a) -> m (Rep a (ZonkAny 1)) -> m a
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inline -> m Inline) -> Rep a (ZonkAny 1) -> m (Rep a (ZonkAny 1))
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasInlines f, Monad m) =>
    (Inline -> m Inline) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> Rep a p -> m (Rep a p)
    gmapInlines Inline -> m Inline
    f (a -> Rep a (ZonkAny 1)
    forall x. a -> Rep a x
    forall a x. Generic a => a -> Rep a x
    from a
    x)

    -- Field: delegate to HasInlines of the field type
    instance HasInlines a => GHasInlines (K1 i a) where
      gfoldInlines :: forall m p. Monoid m => (Inline -> m) -> K1 i a p -> m
    gfoldInlines Inline -> m
    f (K1 a
    x) = (Inline -> m) -> a -> m
    forall m. Monoid m => (Inline -> m) -> a -> m
    forall a m. (HasInlines a, Monoid m) => (Inline -> m) -> a -> m
    foldInlines Inline -> m
    f a
    x
      gmapInlines :: forall (m :: * -> *) p.
    Monad m =>
    (Inline -> m Inline) -> K1 i a p -> m (K1 i a p)
    gmapInlines Inline -> m Inline
    f (K1 a
    x) = a -> K1 i a p
    forall k i c (p :: k). c -> K1 i c p
    K1 (a -> K1 i a p) -> m a -> m (K1 i a p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inline -> m Inline) -> a -> m a
    forall a (m :: * -> *).
    (HasInlines a, Monad m) =>
    (Inline -> m Inline) -> a -> m a
    forall (m :: * -> *). Monad m => (Inline -> m Inline) -> a -> m a
    mapInlines Inline -> m Inline
    f a
    x

    instance {-# OVERLAPPABLE #-} HasInlines a where
      foldInlines :: forall m. Monoid m => (Inline -> m) -> a -> m
    foldInlines Inline -> m
    _ a
    _ = m
    forall a. Monoid a => a
    mempty
      mapInlines :: forall (m :: * -> *). Monad m => (Inline -> m Inline) -> a -> m a
    mapInlines Inline -> m Inline
    _ = a -> m a
    forall a. a -> m a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure

    instance (HasInlines a, Traversable t, Foldable t) => HasInlines (t a) where
      foldInlines :: forall m. Monoid m => (Inline -> m) -> t a -> m
    foldInlines Inline -> m
    f = (a -> m) -> t a -> m
    forall m a. Monoid m => (a -> m) -> t a -> m
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap ((Inline -> m) -> a -> m
    forall m. Monoid m => (Inline -> m) -> a -> m
    forall a m. (HasInlines a, Monoid m) => (Inline -> m) -> a -> m
    foldInlines Inline -> m
    f)
      mapInlines :: forall (m :: * -> *).
    Monad m =>
    (Inline -> m Inline) -> t a -> m (t a)
    mapInlines Inline -> m Inline
    f = (a -> m a) -> t a -> m (t 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) -> t a -> m (t b)
    mapM ((Inline -> m Inline) -> a -> m a
    forall a (m :: * -> *).
    (HasInlines a, Monad m) =>
    (Inline -> m Inline) -> a -> m a
    forall (m :: * -> *). Monad m => (Inline -> m Inline) -> a -> m a
    mapInlines Inline -> m Inline
    f)

    instance HasInlines Inline where
      foldInlines :: forall m. Monoid m => (Inline -> m) -> Inline -> m
    foldInlines Inline -> m
    f i :: Inline
    i@(Inline Attr
    _ InlineType
    ty) =
        Inline -> m
    f Inline
    i m -> m -> m
    forall a. Semigroup a => a -> a -> a
    <> (Inline -> m) -> InlineType -> m
    forall m. Monoid m => (Inline -> m) -> InlineType -> m
    forall a m. (HasInlines a, Monoid m) => (Inline -> m) -> a -> m
    foldInlines Inline -> m
    f InlineType
    ty
      mapInlines :: forall (m :: * -> *).
    Monad m =>
    (Inline -> m Inline) -> Inline -> m Inline
    mapInlines Inline -> m Inline
    f (Inline Attr
    attr InlineType
    ty) =
        (Inline -> m Inline) -> InlineType -> m InlineType
    forall a (m :: * -> *).
    (HasInlines a, Monad m) =>
    (Inline -> m Inline) -> a -> m a
    forall (m :: * -> *).
    Monad m =>
    (Inline -> m Inline) -> InlineType -> m InlineType
    mapInlines Inline -> m Inline
    f InlineType
    ty m InlineType -> (InlineType -> m Inline) -> m Inline
    forall a b. m a -> (a -> m b) -> m b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Inline -> m Inline
    f (Inline -> m Inline)
    -> (InlineType -> Inline) -> InlineType -> m Inline
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attr -> InlineType -> Inline
    Inline Attr
    attr

    instance HasInlines Document
    instance HasInlines Meta
    instance HasInlines Author
    instance HasInlines Block
    instance HasInlines BlockType
    instance HasInlines BlockTitle
    instance HasInlines ListItem
    instance HasInlines TableRow
    instance HasInlines TableCell
    instance HasInlines InlineType

    class GHasBlocks f where
      gfoldBlocks :: Monoid m => (Block -> m) -> f p -> m
      gmapBlocks :: Monad m => (Block -> m Block) -> f p -> m (f p)

    instance GHasBlocks U1 where
      gfoldBlocks :: forall m p. Monoid m => (Block -> m) -> U1 p -> m
    gfoldBlocks Block -> m
    _ U1 p
    _ = m
    forall a. Monoid a => a
    mempty
      gmapBlocks :: forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> U1 p -> m (U1 p)
    gmapBlocks Block -> m Block
    _ U1 p
    _ = U1 p -> m (U1 p)
    forall a. a -> m a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure U1 p
    forall a. Monoid a => a
    mempty

    instance (GHasBlocks f, GHasBlocks g) => GHasBlocks (f :*: g) where
      gfoldBlocks :: forall m p. Monoid m => (Block -> m) -> (:*:) f g p -> m
    gfoldBlocks Block -> m
    f (f p
    x :*: g p
    y) = (Block -> m) -> f p -> m
    forall m p. Monoid m => (Block -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f f p
    x m -> m -> m
    forall a. Semigroup a => a -> a -> a
    <> (Block -> m) -> g p -> m
    forall m p. Monoid m => (Block -> m) -> g p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f g p
    y
      gmapBlocks :: forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> (:*:) f g p -> m ((:*:) f g p)
    gmapBlocks Block -> m Block
    f (f p
    x :*: g p
    y) = (f p -> g p -> (:*:) f g p)
    -> m (f p) -> m (g p) -> m ((:*:) f g p)
    forall (m :: * -> *) a1 a2 r.
    Monad m =>
    (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
    liftM2 f p -> g p -> (:*:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k).
    f p -> g p -> (:*:) f g p
    (:*:) ((Block -> m Block) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> f p -> m (f p)
    gmapBlocks Block -> m Block
    f f p
    x) ((Block -> m Block) -> g p -> m (g p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> g p -> m (g p)
    gmapBlocks Block -> m Block
    f g p
    y)

    instance (GHasBlocks f, GHasBlocks g) => GHasBlocks (f :+: g) where
      gfoldBlocks :: forall m p. Monoid m => (Block -> m) -> (:+:) f g p -> m
    gfoldBlocks Block -> m
    f (L1 f p
    x) = (Block -> m) -> f p -> m
    forall m p. Monoid m => (Block -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f f p
    x
      gfoldBlocks Block -> m
    f (R1 g p
    y) = (Block -> m) -> g p -> m
    forall m p. Monoid m => (Block -> m) -> g p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f g p
    y
      gmapBlocks :: forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> (:+:) f g p -> m ((:+:) f g p)
    gmapBlocks Block -> m Block
    f (L1 f p
    x) = f p -> (:+:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
    L1 (f p -> (:+:) f g p) -> m (f p) -> m ((:+:) f g p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Block -> m Block) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> f p -> m (f p)
    gmapBlocks Block -> m Block
    f f p
    x
      gmapBlocks Block -> m Block
    f (R1 g p
    y) = g p -> (:+:) f g p
    forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
    R1 (g p -> (:+:) f g p) -> m (g p) -> m ((:+:) f g p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Block -> m Block) -> g p -> m (g p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> g p -> m (g p)
    gmapBlocks Block -> m Block
    f g p
    y

    instance GHasBlocks f => GHasBlocks (M1 i c f) where
      gfoldBlocks :: forall m p. Monoid m => (Block -> m) -> M1 i c f p -> m
    gfoldBlocks Block -> m
    f (M1 f p
    x) = (Block -> m) -> f p -> m
    forall m p. Monoid m => (Block -> m) -> f p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f f p
    x
      gmapBlocks :: forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> M1 i c f p -> m (M1 i c f p)
    gmapBlocks Block -> m Block
    f (M1 f p
    x) = f p -> M1 i c f p
    forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
    M1 (f p -> M1 i c f p) -> m (f p) -> m (M1 i c f p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Block -> m Block) -> f p -> m (f p)
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> f p -> m (f p)
    gmapBlocks Block -> m Block
    f f p
    x

    class HasBlocks a where
      foldBlocks :: Monoid m => (Block -> m) -> a -> m
      mapBlocks :: Monad m => (Block -> m Block) -> a -> m a

      default foldBlocks :: (Generic a, GHasBlocks (Rep a), Monoid m)
                          => (Block -> m) -> a -> m
      foldBlocks Block -> m
    f = (Block -> m) -> Rep a (ZonkAny 2) -> m
    forall m p. Monoid m => (Block -> m) -> Rep a p -> m
    forall (f :: * -> *) m p.
    (GHasBlocks f, Monoid m) =>
    (Block -> m) -> f p -> m
    gfoldBlocks Block -> m
    f (Rep a (ZonkAny 2) -> m) -> (a -> Rep a (ZonkAny 2)) -> a -> m
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Rep a (ZonkAny 2)
    forall x. a -> Rep a x
    forall a x. Generic a => a -> Rep a x
    from

      default mapBlocks :: (Generic a, GHasBlocks (Rep a), Monad m)
                          => (Block -> m Block) -> a -> m a
      mapBlocks Block -> m Block
    f a
    x = Rep a (ZonkAny 3) -> a
    forall a x. Generic a => Rep a x -> a
    forall x. Rep a x -> a
    to (Rep a (ZonkAny 3) -> a) -> m (Rep a (ZonkAny 3)) -> m a
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Block -> m Block) -> Rep a (ZonkAny 3) -> m (Rep a (ZonkAny 3))
    forall (f :: * -> *) (m :: * -> *) p.
    (GHasBlocks f, Monad m) =>
    (Block -> m Block) -> f p -> m (f p)
    forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> Rep a p -> m (Rep a p)
    gmapBlocks Block -> m Block
    f (a -> Rep a (ZonkAny 3)
    forall x. a -> Rep a x
    forall a x. Generic a => a -> Rep a x
    from a
    x)

    -- Field: delegate to HasBlocks of the field type
    instance HasBlocks a => GHasBlocks (K1 i a) where
      gfoldBlocks :: forall m p. Monoid m => (Block -> m) -> K1 i a p -> m
    gfoldBlocks Block -> m
    f (K1 a
    x) = (Block -> m) -> a -> m
    forall m. Monoid m => (Block -> m) -> a -> m
    forall a m. (HasBlocks a, Monoid m) => (Block -> m) -> a -> m
    foldBlocks Block -> m
    f a
    x
      gmapBlocks :: forall (m :: * -> *) p.
    Monad m =>
    (Block -> m Block) -> K1 i a p -> m (K1 i a p)
    gmapBlocks Block -> m Block
    f (K1 a
    x) = a -> K1 i a p
    forall k i c (p :: k). c -> K1 i c p
    K1 (a -> K1 i a p) -> m a -> m (K1 i a p)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Block -> m Block) -> a -> m a
    forall a (m :: * -> *).
    (HasBlocks a, Monad m) =>
    (Block -> m Block) -> a -> m a
    forall (m :: * -> *). Monad m => (Block -> m Block) -> a -> m a
    mapBlocks Block -> m Block
    f a
    x

    instance {-# OVERLAPPABLE #-} HasBlocks a where
      foldBlocks :: forall m. Monoid m => (Block -> m) -> a -> m
    foldBlocks Block -> m
    _ a
    _ = m
    forall a. Monoid a => a
    mempty
      mapBlocks :: forall (m :: * -> *). Monad m => (Block -> m Block) -> a -> m a
    mapBlocks Block -> m Block
    _ = a -> m a
    forall a. a -> m a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure

    instance (HasBlocks a, Traversable t, Foldable t) => HasBlocks (t a) where
      foldBlocks :: forall m. Monoid m => (Block -> m) -> t a -> m
    foldBlocks Block -> m
    f = (a -> m) -> t a -> m
    forall m a. Monoid m => (a -> m) -> t a -> m
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap ((Block -> m) -> a -> m
    forall m. Monoid m => (Block -> m) -> a -> m
    forall a m. (HasBlocks a, Monoid m) => (Block -> m) -> a -> m
    foldBlocks Block -> m
    f)
      mapBlocks :: forall (m :: * -> *).
    Monad m =>
    (Block -> m Block) -> t a -> m (t a)
    mapBlocks Block -> m Block
    f = (a -> m a) -> t a -> m (t 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) -> t a -> m (t b)
    mapM ((Block -> m Block) -> a -> m a
    forall a (m :: * -> *).
    (HasBlocks a, Monad m) =>
    (Block -> m Block) -> a -> m a
    forall (m :: * -> *). Monad m => (Block -> m Block) -> a -> m a
    mapBlocks Block -> m Block
    f)

    instance HasBlocks Block where
      foldBlocks :: forall m. Monoid m => (Block -> m) -> Block -> m
    foldBlocks Block -> m
    f i :: Block
    i@(Block Attr
    _ Maybe BlockTitle
    _ BlockType
    ty) =
        Block -> m
    f Block
    i m -> m -> m
    forall a. Semigroup a => a -> a -> a
    <> (Block -> m) -> BlockType -> m
    forall m. Monoid m => (Block -> m) -> BlockType -> m
    forall a m. (HasBlocks a, Monoid m) => (Block -> m) -> a -> m
    foldBlocks Block -> m
    f BlockType
    ty
      mapBlocks :: forall (m :: * -> *).
    Monad m =>
    (Block -> m Block) -> Block -> m Block
    mapBlocks Block -> m Block
    f (Block Attr
    attr Maybe BlockTitle
    mbtit BlockType
    ty) =
        (Block -> m Block) -> BlockType -> m BlockType
    forall a (m :: * -> *).
    (HasBlocks a, Monad m) =>
    (Block -> m Block) -> a -> m a
    forall (m :: * -> *).
    Monad m =>
    (Block -> m Block) -> BlockType -> m BlockType
    mapBlocks Block -> m Block
    f BlockType
    ty m BlockType -> (BlockType -> m Block) -> m Block
    forall a b. m a -> (a -> m b) -> m b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Block -> m Block
    f (Block -> m Block) -> (BlockType -> Block) -> BlockType -> m Block
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attr -> Maybe BlockTitle -> BlockType -> Block
    Block Attr
    attr Maybe BlockTitle
    mbtit

    instance HasBlocks Document
    instance HasBlocks Meta
    instance HasBlocks Inline
    instance HasBlocks InlineType
    instance HasBlocks ListItem
    instance HasBlocks TableRow
    instance HasBlocks TableCell
    instance HasBlocks BlockType