    {-# OPTIONS_GHC -fno-warn-orphans #-}
    {-# LANGUAGE FlexibleInstances, ScopedTypeVariables, OverloadedStrings #-}
    -- provides Arbitrary instance for Pandoc types
    module Text.Pandoc.Arbitrary ()
    where
    import Test.QuickCheck
    import Control.Monad (forM)
    import Data.Text (Text)
    import qualified Data.Text as T
    import Text.Pandoc.Definition
    import Text.Pandoc.Builder

    realString :: Gen Text
    realString :: Gen Text
    realString = (String -> Text) -> Gen String -> Gen Text
    forall a b. (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap String -> Text
    T.pack (Gen String -> Gen Text) -> Gen String -> Gen Text
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen String -> Gen String
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    8 (Gen String -> Gen String) -> Gen String -> Gen String
    forall a b. (a -> b) -> a -> b
    $ Gen Char -> Gen String
    forall a. Gen a -> Gen [a]
    listOf (Gen Char -> Gen String) -> Gen Char -> Gen String
    forall a b. (a -> b) -> a -> b
    $ [(Int, Gen Char)] -> Gen Char
    forall a. HasCallStack => [(Int, Gen a)] -> Gen a
    frequency [ (Int
    9, String -> Gen Char
    forall a. HasCallStack => [a] -> Gen a
    elements [Char
    ' '..Char
    '\127'])
                                                             , (Int
    1, String -> Gen Char
    forall a. HasCallStack => [a] -> Gen a
    elements [Char
    '\128'..Char
    '\9999']) ]

    shrinkText :: Text -> [Text]
    shrinkText :: Text -> [Text]
    shrinkText Text
    xs = String -> Text
    T.pack (String -> Text) -> [String] -> [Text]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> [String]
    forall a. Arbitrary a => a -> [a]
    shrink (Text -> String
    T.unpack Text
    xs)

    shrinkText2 :: (Text, Text) -> [(Text, Text)]
    shrinkText2 :: (Text, Text) -> [(Text, Text)]
    shrinkText2 = (Text -> [Text])
    -> (Text -> [Text]) -> (Text, Text) -> [(Text, Text)]
    forall a b. (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
    forall (f :: * -> * -> *) a b.
    Arbitrary2 f =>
    (a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
    liftShrink2 Text -> [Text]
    shrinkText Text -> [Text]
    shrinkText

    arbAttr :: Gen Attr
    arbAttr :: Gen Attr
    arbAttr = do
      id' <- [Text] -> Gen Text
    forall a. HasCallStack => [a] -> Gen a
    elements [Text
    "",Text
    "loc"]
      classes' <- elements [[],["haskell"],["c","numberLines"]]
      keyvals <- elements [[],[("start","22")],[("a","11"),("b_2","a b c")]]
      return (id',classes',keyvals)

    shrinkAttr :: Attr -> [Attr]
    shrinkAttr :: Attr -> [Attr]
    shrinkAttr (Text
    a, [Text]
    b, [(Text, Text)]
    c)
      = [ (Text
    a', [Text]
    b', [(Text, Text)]
    c') | Text
    a' <- Text -> [Text]
    shrinkText Text
    a,
                         [Text]
    b' <- (Text -> [Text]) -> [Text] -> [[Text]]
    forall a. (a -> [a]) -> [a] -> [[a]]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink Text -> [Text]
    shrinkText [Text]
    b,
                         [(Text, Text)]
    c' <- ((Text, Text) -> [(Text, Text)])
    -> [(Text, Text)] -> [[(Text, Text)]]
    forall a. (a -> [a]) -> [a] -> [[a]]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink (Text, Text) -> [(Text, Text)]
    shrinkText2 [(Text, Text)]
    c ]

    instance Arbitrary Inlines where
      arbitrary :: Gen (Many Inline)
    arbitrary = ([Inline] -> Many Inline
    forall a. [a] -> Many a
    fromList :: [Inline] -> Inlines) ([Inline] -> Many Inline) -> Gen [Inline] -> Gen (Many Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen [Inline]
    forall a. Arbitrary a => Gen a
    arbitrary
      shrink :: Many Inline -> [Many Inline]
    shrink = ([Inline] -> Many Inline) -> [[Inline]] -> [Many Inline]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Inline] -> Many Inline
    forall a. [a] -> Many a
    fromList ([[Inline]] -> [Many Inline])
    -> (Many Inline -> [[Inline]]) -> Many Inline -> [Many Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([[Inline]] -> [[Inline]] -> [[Inline]]
    forall a. [a] -> [a] -> [a]
    (++) ([[Inline]] -> [[Inline]] -> [[Inline]])
    -> ([Inline] -> [[Inline]]) -> [Inline] -> [[Inline]] -> [[Inline]]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    forall a. Arbitrary a => a -> [a]
    shrink ([Inline] -> [[Inline]] -> [[Inline]])
    -> ([Inline] -> [[Inline]]) -> [Inline] -> [[Inline]]
    forall a b.
    ([Inline] -> a -> b) -> ([Inline] -> a) -> [Inline] -> b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Inline] -> [[Inline]]
    flattenShrinkInlines) ([Inline] -> [[Inline]])
    -> (Many Inline -> [Inline]) -> Many Inline -> [[Inline]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Many Inline -> [Inline]
    forall a. Many a -> [a]
    toList
        where flattenShrinkInlines :: [Inline] -> [[Inline]]
    flattenShrinkInlines (Inline
    x:[Inline]
    xs) =
                let x' :: [Inline]
    x' = Inline -> [Inline]
    flattenInline Inline
    x
                in [[Inline]
    x' [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Inline]
    xs | Bool -> Bool
    not ([Inline] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Inline]
    x')] [[Inline]] -> [[Inline]] -> [[Inline]]
    forall a. [a] -> [a] -> [a]
    ++ [Inline
    xInline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    :[Inline]
    xs' | [Inline]
    xs' <- [Inline] -> [[Inline]]
    flattenShrinkInlines [Inline]
    xs]
              flattenShrinkInlines [] = []
              flattenInline :: Inline -> [Inline]
              flattenInline :: Inline -> [Inline]
    flattenInline (Str Text
    _) = []
              flattenInline (Emph [Inline]
    ils) = [Inline]
    ils
              flattenInline (Underline [Inline]
    ils) = [Inline]
    ils
              flattenInline (Strong [Inline]
    ils) = [Inline]
    ils
              flattenInline (Strikeout [Inline]
    ils) = [Inline]
    ils
              flattenInline (Superscript [Inline]
    ils) = [Inline]
    ils
              flattenInline (Subscript [Inline]
    ils) = [Inline]
    ils
              flattenInline (SmallCaps [Inline]
    ils) = [Inline]
    ils
              flattenInline (Quoted QuoteType
    _ [Inline]
    ils) = [Inline]
    ils
              flattenInline (Cite [Citation]
    _ [Inline]
    ils) = [Inline]
    ils
              flattenInline Code{} = []
              flattenInline Inline
    Space = []
              flattenInline Inline
    SoftBreak = []
              flattenInline Inline
    LineBreak = []
              flattenInline Math{} = []
              flattenInline RawInline{} = []
              flattenInline (Link Attr
    _ [Inline]
    ils (Text, Text)
    _) = [Inline]
    ils
              flattenInline (Image Attr
    _ [Inline]
    ils (Text, Text)
    _) = [Inline]
    ils
              flattenInline Note{} = []
              flattenInline (Span Attr
    _ [Inline]
    ils) = [Inline]
    ils

    instance Arbitrary Blocks where
      arbitrary :: Gen (Many Block)
    arbitrary = ([Block] -> Many Block
    forall a. [a] -> Many a
    fromList :: [Block] -> Blocks) ([Block] -> Many Block) -> Gen [Block] -> Gen (Many Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen [Block]
    forall a. Arbitrary a => Gen a
    arbitrary
      shrink :: Many Block -> [Many Block]
    shrink = ([Block] -> Many Block) -> [[Block]] -> [Many Block]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Block] -> Many Block
    forall a. [a] -> Many a
    fromList ([[Block]] -> [Many Block])
    -> (Many Block -> [[Block]]) -> Many Block -> [Many Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([[Block]] -> [[Block]] -> [[Block]]
    forall a. [a] -> [a] -> [a]
    (++) ([[Block]] -> [[Block]] -> [[Block]])
    -> ([Block] -> [[Block]]) -> [Block] -> [[Block]] -> [[Block]]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Block] -> [[Block]]
    forall a. Arbitrary a => a -> [a]
    shrink ([Block] -> [[Block]] -> [[Block]])
    -> ([Block] -> [[Block]]) -> [Block] -> [[Block]]
    forall a b. ([Block] -> a -> b) -> ([Block] -> a) -> [Block] -> b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Block] -> [[Block]]
    flattenShrinkBlocks) ([Block] -> [[Block]])
    -> (Many Block -> [Block]) -> Many Block -> [[Block]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Many Block -> [Block]
    forall a. Many a -> [a]
    toList
        where flattenShrinkBlocks :: [Block] -> [[Block]]
    flattenShrinkBlocks (Block
    x:[Block]
    xs) =
                let x' :: [Block]
    x' = Block -> [Block]
    flattenBlock Block
    x
                in [[Block]
    x' [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++ [Block]
    xs | Bool -> Bool
    not ([Block] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Block]
    x')] [[Block]] -> [[Block]] -> [[Block]]
    forall a. [a] -> [a] -> [a]
    ++ [Block
    xBlock -> [Block] -> [Block]
    forall a. a -> [a] -> [a]
    :[Block]
    xs' | [Block]
    xs' <- [Block] -> [[Block]]
    flattenShrinkBlocks [Block]
    xs]
              flattenShrinkBlocks [] = []
              flattenBlock :: Block -> [Block]
              flattenBlock :: Block -> [Block]
    flattenBlock Plain{} = []
              flattenBlock Para{} = []
              flattenBlock (LineBlock [[Inline]]
    lns) = [[Inline] -> Block
    Para [Inline]
    x | [Inline]
    x <- [[Inline]]
    lns]
              flattenBlock CodeBlock{} = []
              flattenBlock RawBlock{} = []
              flattenBlock (BlockQuote [Block]
    blks) = [Block]
    blks
              flattenBlock (OrderedList ListAttributes
    _ [[Block]]
    blksList) = [[Block]] -> [Block]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [[Block]]
    blksList
              flattenBlock (BulletList [[Block]]
    blksList) = [[Block]] -> [Block]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [[Block]]
    blksList
              flattenBlock (DefinitionList [([Inline], [[Block]])]
    defs) = [[Block]] -> [Block]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [[Inline] -> Block
    Para [Inline]
    ilsBlock -> [Block] -> [Block]
    forall a. a -> [a] -> [a]
    :[[Block]] -> [Block]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [[Block]]
    blks | ([Inline]
    ils, [[Block]]
    blks) <- [([Inline], [[Block]])]
    defs]
              flattenBlock (Header Int
    _ Attr
    _ [Inline]
    ils) = [[Inline] -> Block
    Para [Inline]
    ils]
              flattenBlock Block
    HorizontalRule = []
              flattenBlock (Table Attr
    _ Caption
    capt [ColSpec]
    _ TableHead
    hd [TableBody]
    bd TableFoot
    ft) = Caption -> [Block]
    flattenCaption Caption
    capt [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <>
                                                       TableHead -> [Block]
    flattenTableHead TableHead
    hd [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <>
                                                       (TableBody -> [Block]) -> [TableBody] -> [Block]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap TableBody -> [Block]
    flattenTableBody [TableBody]
    bd [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <>
                                                       TableFoot -> [Block]
    flattenTableFoot TableFoot
    ft
              flattenBlock (Figure Attr
    _ Caption
    capt [Block]
    blks) = Caption -> [Block]
    flattenCaption Caption
    capt [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <> [Block]
    blks
              flattenBlock (Div Attr
    _ [Block]
    blks) = [Block]
    blks

              flattenCaption :: Caption -> [Block]
    flattenCaption (Caption Maybe [Inline]
    Nothing [Block]
    body)    = [Block]
    body
              flattenCaption (Caption (Just [Inline]
    ils) [Block]
    body) = [Inline] -> Block
    Para [Inline]
    ils Block -> [Block] -> [Block]
    forall a. a -> [a] -> [a]
    : [Block]
    body

              flattenTableHead :: TableHead -> [Block]
    flattenTableHead (TableHead Attr
    _ [Row]
    body) = [Row] -> [Block]
    flattenRows [Row]
    body
              flattenTableBody :: TableBody -> [Block]
    flattenTableBody (TableBody Attr
    _ RowHeadColumns
    _ [Row]
    hd [Row]
    bd) = [Row] -> [Block]
    flattenRows [Row]
    hd [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <> [Row] -> [Block]
    flattenRows [Row]
    bd
              flattenTableFoot :: TableFoot -> [Block]
    flattenTableFoot (TableFoot Attr
    _ [Row]
    body) = [Row] -> [Block]
    flattenRows [Row]
    body

              flattenRows :: [Row] -> [Block]
    flattenRows = (Row -> [Block]) -> [Row] -> [Block]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Row -> [Block]
    flattenRow
              flattenRow :: Row -> [Block]
    flattenRow (Row Attr
    _ [Cell]
    body) = (Cell -> [Block]) -> [Cell] -> [Block]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Cell -> [Block]
    flattenCell [Cell]
    body
              flattenCell :: Cell -> [Block]
    flattenCell (Cell Attr
    _ Alignment
    _ RowSpan
    _ ColSpan
    _ [Block]
    blks) = [Block]
    blks

    shrinkInlineList :: [Inline] -> [[Inline]]
    shrinkInlineList :: [Inline] -> [[Inline]]
    shrinkInlineList = (Many Inline -> [Inline]) -> [Many Inline] -> [[Inline]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Many Inline -> [Inline]
    forall a. Many a -> [a]
    toList ([Many Inline] -> [[Inline]])
    -> ([Inline] -> [Many Inline]) -> [Inline] -> [[Inline]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Many Inline -> [Many Inline]
    forall a. Arbitrary a => a -> [a]
    shrink (Many Inline -> [Many Inline])
    -> ([Inline] -> Many Inline) -> [Inline] -> [Many Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> Many Inline
    forall a. [a] -> Many a
    fromList

    shrinkInlinesList :: [[Inline]] -> [[[Inline]]]
    shrinkInlinesList :: [[Inline]] -> [[[Inline]]]
    shrinkInlinesList = ([Many Inline] -> [[Inline]]) -> [[Many Inline]] -> [[[Inline]]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Many Inline -> [Inline]) -> [Many Inline] -> [[Inline]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Many Inline -> [Inline]
    forall a. Many a -> [a]
    toList) ([[Many Inline]] -> [[[Inline]]])
    -> ([[Inline]] -> [[Many Inline]]) -> [[Inline]] -> [[[Inline]]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Many Inline] -> [[Many Inline]]
    forall a. Arbitrary a => a -> [a]
    shrink ([Many Inline] -> [[Many Inline]])
    -> ([[Inline]] -> [Many Inline]) -> [[Inline]] -> [[Many Inline]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Inline] -> Many Inline) -> [[Inline]] -> [Many Inline]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Inline] -> Many Inline
    forall a. [a] -> Many a
    fromList

    shrinkBlockList :: [Block] -> [[Block]]
    shrinkBlockList :: [Block] -> [[Block]]
    shrinkBlockList = (Many Block -> [Block]) -> [Many Block] -> [[Block]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Many Block -> [Block]
    forall a. Many a -> [a]
    toList ([Many Block] -> [[Block]])
    -> ([Block] -> [Many Block]) -> [Block] -> [[Block]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Many Block -> [Many Block]
    forall a. Arbitrary a => a -> [a]
    shrink (Many Block -> [Many Block])
    -> ([Block] -> Many Block) -> [Block] -> [Many Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Block] -> Many Block
    forall a. [a] -> Many a
    fromList

    shrinkBlocksList :: [[Block]] -> [[[Block]]]
    shrinkBlocksList :: [[Block]] -> [[[Block]]]
    shrinkBlocksList = ([Many Block] -> [[Block]]) -> [[Many Block]] -> [[[Block]]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Many Block -> [Block]) -> [Many Block] -> [[Block]]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Many Block -> [Block]
    forall a. Many a -> [a]
    toList) ([[Many Block]] -> [[[Block]]])
    -> ([[Block]] -> [[Many Block]]) -> [[Block]] -> [[[Block]]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Many Block] -> [[Many Block]]
    forall a. Arbitrary a => a -> [a]
    shrink ([Many Block] -> [[Many Block]])
    -> ([[Block]] -> [Many Block]) -> [[Block]] -> [[Many Block]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Block] -> Many Block) -> [[Block]] -> [Many Block]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Block] -> Many Block
    forall a. [a] -> Many a
    fromList

    instance Arbitrary Inline where
      arbitrary :: Gen Inline
    arbitrary = Int -> Gen Inline -> Gen Inline
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen Inline -> Gen Inline) -> Gen Inline -> Gen Inline
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Inline
    arbInline Int
    2
      shrink :: Inline -> [Inline]
    shrink (Str Text
    s) = Text -> Inline
    Str (Text -> Inline) -> [Text] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s
      shrink (Emph [Inline]
    ils) = [Inline] -> Inline
    Emph ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Underline [Inline]
    ils) = [Inline] -> Inline
    Underline ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Strong [Inline]
    ils) = [Inline] -> Inline
    Strong ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Strikeout [Inline]
    ils) = [Inline] -> Inline
    Strikeout ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Superscript [Inline]
    ils) = [Inline] -> Inline
    Superscript ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Subscript [Inline]
    ils) = [Inline] -> Inline
    Subscript ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (SmallCaps [Inline]
    ils) = [Inline] -> Inline
    SmallCaps ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Quoted QuoteType
    qtype [Inline]
    ils) = QuoteType -> [Inline] -> Inline
    Quoted QuoteType
    qtype ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Cite [Citation]
    cits [Inline]
    ils) = ([Citation] -> [Inline] -> Inline
    Cite [Citation]
    cits ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils)
                            [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ (([Citation] -> [Inline] -> Inline)
    -> [Inline] -> [Citation] -> Inline
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip [Citation] -> [Inline] -> Inline
    Cite [Inline]
    ils ([Citation] -> Inline) -> [[Citation]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Citation] -> [[Citation]]
    forall a. Arbitrary a => a -> [a]
    shrink [Citation]
    cits)
      shrink (Code Attr
    attr Text
    s) = (Attr -> Text -> Inline
    Code Attr
    attr (Text -> Inline) -> [Text] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s)
                          [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ ((Attr -> Text -> Inline) -> Text -> Attr -> Inline
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Attr -> Text -> Inline
    Code Text
    s (Attr -> Inline) -> [Attr] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr -> [Attr]
    shrinkAttr Attr
    attr)
      shrink Inline
    Space = []
      shrink Inline
    SoftBreak = []
      shrink Inline
    LineBreak = []
      shrink (Math MathType
    mtype Text
    s) = MathType -> Text -> Inline
    Math MathType
    mtype (Text -> Inline) -> [Text] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s
      shrink (RawInline Format
    fmt Text
    s) = Format -> Text -> Inline
    RawInline Format
    fmt (Text -> Inline) -> [Text] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s
      shrink (Link Attr
    attr [Inline]
    ils (Text, Text)
    target) = [Attr -> [Inline] -> (Text, Text) -> Inline
    Link Attr
    attr [Inline]
    ils' (Text, Text)
    target | [Inline]
    ils' <- [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils]
                                   [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Attr -> [Inline] -> (Text, Text) -> Inline
    Link Attr
    attr [Inline]
    ils (Text, Text)
    target' | (Text, Text)
    target' <- (Text, Text) -> [(Text, Text)]
    shrinkText2 (Text, Text)
    target]
                                   [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Attr -> [Inline] -> (Text, Text) -> Inline
    Link Attr
    attr' [Inline]
    ils (Text, Text)
    target | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr]
      shrink (Image Attr
    attr [Inline]
    ils (Text, Text)
    target) = [Attr -> [Inline] -> (Text, Text) -> Inline
    Image Attr
    attr [Inline]
    ils' (Text, Text)
    target | [Inline]
    ils' <- [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils]
                                    [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Attr -> [Inline] -> (Text, Text) -> Inline
    Image Attr
    attr [Inline]
    ils (Text, Text)
    target' | (Text, Text)
    target' <- (Text, Text) -> [(Text, Text)]
    shrinkText2 (Text, Text)
    target]
                                    [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Attr -> [Inline] -> (Text, Text) -> Inline
    Image Attr
    attr' [Inline]
    ils (Text, Text)
    target | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr]
      shrink (Note [Block]
    blks) = [Block] -> Inline
    Note ([Block] -> Inline) -> [[Block]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Block] -> [[Block]]
    shrinkBlockList [Block]
    blks
      shrink (Span Attr
    attr [Inline]
    s) = (Attr -> [Inline] -> Inline
    Span Attr
    attr ([Inline] -> Inline) -> [[Inline]] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    forall a. Arbitrary a => a -> [a]
    shrink [Inline]
    s)
                          [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ ((Attr -> [Inline] -> Inline) -> [Inline] -> Attr -> Inline
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Attr -> [Inline] -> Inline
    Span [Inline]
    s (Attr -> Inline) -> [Attr] -> [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr -> [Attr]
    shrinkAttr Attr
    attr)

    arbInlines :: Int -> Gen [Inline]
    arbInlines :: Int -> Gen [Inline]
    arbInlines Int
    n = Gen Inline -> Gen [Inline]
    forall a. Gen a -> Gen [a]
    listOf1 (Int -> Gen Inline
    arbInline Int
    n) Gen [Inline] -> ([Inline] -> Bool) -> Gen [Inline]
    forall a. Gen a -> (a -> Bool) -> Gen a
    `suchThat` (Bool -> Bool
    not (Bool -> Bool) -> ([Inline] -> Bool) -> [Inline] -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> Bool
    startsWithSpace)
      where startsWithSpace :: [Inline] -> Bool
    startsWithSpace (Inline
    Space:[Inline]
    _)     = Bool
    True
            startsWithSpace (Inline
    SoftBreak:[Inline]
    _) = Bool
    True
            -- Note: no LineBreak, similarly to Text.Pandoc.Builder (trimInlines)
            startsWithSpace [Inline]
    _             = Bool
    False

    -- restrict to 3 levels of nesting max; otherwise we get
    -- bogged down in indefinitely large structures
    arbInline :: Int -> Gen Inline
    arbInline :: Int -> Gen Inline
    arbInline Int
    n = [(Int, Gen Inline)] -> Gen Inline
    forall a. HasCallStack => [(Int, Gen a)] -> Gen a
    frequency ([(Int, Gen Inline)] -> Gen Inline)
    -> [(Int, Gen Inline)] -> Gen Inline
    forall a b. (a -> b) -> a -> b
    $ [ (Int
    60, Text -> Inline
    Str (Text -> Inline) -> Gen Text -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Text
    realString)
                              , (Int
    40, Inline -> Gen Inline
    forall a. a -> Gen a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Inline
    Space)
                              , (Int
    10, Inline -> Gen Inline
    forall a. a -> Gen a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Inline
    SoftBreak)
                              , (Int
    10, Inline -> Gen Inline
    forall a. a -> Gen a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Inline
    LineBreak)
                              , (Int
    10, Attr -> Text -> Inline
    Code (Attr -> Text -> Inline) -> Gen Attr -> Gen (Text -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen (Text -> Inline) -> Gen Text -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Text
    realString)
                              , (Int
    5,  [Inline] -> Gen Inline
    forall a. HasCallStack => [a] -> Gen a
    elements [ Format -> Text -> Inline
    RawInline (Text -> Format
    Format Text
    "html") Text
    "<a id=\"eek\">"
                                              , Format -> Text -> Inline
    RawInline (Text -> Format
    Format Text
    "latex") Text
    "\\my{command}" ])
                              ] [(Int, Gen Inline)] -> [(Int, Gen Inline)] -> [(Int, Gen Inline)]
    forall a. [a] -> [a] -> [a]
    ++ [ (Int, Gen Inline)
    x | Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    1, (Int, Gen Inline)
    x <- [(Int, Gen Inline)]
    nesters]
       where nesters :: [(Int, Gen Inline)]
    nesters = [ (Int
    10, [Inline] -> Inline
    Emph ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    Underline ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    Strong ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    Strikeout ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    Superscript ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    Subscript ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, [Inline] -> Inline
    SmallCaps ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, Attr -> [Inline] -> Inline
    Span (Attr -> [Inline] -> Inline)
    -> Gen Attr -> Gen ([Inline] -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, QuoteType -> [Inline] -> Inline
    Quoted (QuoteType -> [Inline] -> Inline)
    -> Gen QuoteType -> Gen ([Inline] -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen QuoteType
    forall a. Arbitrary a => Gen a
    arbitrary Gen ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                       , (Int
    10, MathType -> Text -> Inline
    Math (MathType -> Text -> Inline)
    -> Gen MathType -> Gen (Text -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen MathType
    forall a. Arbitrary a => Gen a
    arbitrary Gen (Text -> Inline) -> Gen Text -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Text
    realString)
                       , (Int
    10, Attr -> [Inline] -> (Text, Text) -> Inline
    Link (Attr -> [Inline] -> (Text, Text) -> Inline)
    -> Gen Attr -> Gen ([Inline] -> (Text, Text) -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen ([Inline] -> (Text, Text) -> Inline)
    -> Gen [Inline] -> Gen ((Text, Text) -> Inline)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1) Gen ((Text, Text) -> Inline) -> Gen (Text, Text) -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ((,) (Text -> Text -> (Text, Text))
    -> Gen Text -> Gen (Text -> (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Text
    realString Gen (Text -> (Text, Text)) -> Gen Text -> Gen (Text, Text)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Text
    realString))
                       , (Int
    10, Attr -> [Inline] -> (Text, Text) -> Inline
    Image (Attr -> [Inline] -> (Text, Text) -> Inline)
    -> Gen Attr -> Gen ([Inline] -> (Text, Text) -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen ([Inline] -> (Text, Text) -> Inline)
    -> Gen [Inline] -> Gen ((Text, Text) -> Inline)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1) Gen ((Text, Text) -> Inline) -> Gen (Text, Text) -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ((,) (Text -> Text -> (Text, Text))
    -> Gen Text -> Gen (Text -> (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Text
    realString Gen (Text -> (Text, Text)) -> Gen Text -> Gen (Text, Text)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Text
    realString))
                       , (Int
    2,  [Citation] -> [Inline] -> Inline
    Cite ([Citation] -> [Inline] -> Inline)
    -> Gen [Citation] -> Gen ([Inline] -> Inline)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen [Citation]
    forall a. Arbitrary a => Gen a
    arbitrary Gen ([Inline] -> Inline) -> Gen [Inline] -> Gen Inline
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines Int
    1)
                       , (Int
    2,  [Block] -> Inline
    Note ([Block] -> Inline) -> Gen [Block] -> Gen Inline
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Block] -> Gen [Block]
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]) -> Gen Block -> Gen [Block]
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       ]

    instance Arbitrary Block where
      arbitrary :: Gen Block
    arbitrary = Int -> Gen Block -> Gen Block
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen Block -> Gen Block) -> Gen Block -> Gen Block
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Block
    arbBlock Int
    2
      shrink :: Block -> [Block]
    shrink (Plain [Inline]
    ils) = [Inline] -> Block
    Plain ([Inline] -> Block) -> [[Inline]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (Para [Inline]
    ils) = [Inline] -> Block
    Para ([Inline] -> Block) -> [[Inline]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils
      shrink (LineBlock [[Inline]]
    lns) = [[Inline]] -> Block
    LineBlock ([[Inline]] -> Block) -> [[[Inline]]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [[Inline]] -> [[[Inline]]]
    shrinkInlinesList [[Inline]]
    lns
      shrink (CodeBlock Attr
    attr Text
    s) = (Attr -> Text -> Block
    CodeBlock Attr
    attr (Text -> Block) -> [Text] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s)
                               [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++ ((Attr -> Text -> Block) -> Text -> Attr -> Block
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Attr -> Text -> Block
    CodeBlock Text
    s (Attr -> Block) -> [Attr] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr -> [Attr]
    shrinkAttr Attr
    attr)
      shrink (RawBlock Format
    fmt Text
    s) = Format -> Text -> Block
    RawBlock Format
    fmt (Text -> Block) -> [Text] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> [Text]
    shrinkText Text
    s
      shrink (BlockQuote [Block]
    blks) = [Block] -> Block
    BlockQuote ([Block] -> Block) -> [[Block]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Block] -> [[Block]]
    shrinkBlockList [Block]
    blks
      shrink (OrderedList ListAttributes
    listAttrs [[Block]]
    blksList) = ListAttributes -> [[Block]] -> Block
    OrderedList ListAttributes
    listAttrs ([[Block]] -> Block) -> [[[Block]]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [[Block]] -> [[[Block]]]
    shrinkBlocksList [[Block]]
    blksList
      shrink (BulletList [[Block]]
    blksList) = [[Block]] -> Block
    BulletList ([[Block]] -> Block) -> [[[Block]]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [[Block]] -> [[[Block]]]
    shrinkBlocksList [[Block]]
    blksList
      shrink (DefinitionList [([Inline], [[Block]])]
    defs) = [([Inline], [[Block]])] -> Block
    DefinitionList ([([Inline], [[Block]])] -> Block)
    -> [[([Inline], [[Block]])]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [([Inline], [[Block]])] -> [[([Inline], [[Block]])]]
    shrinkDefinitionList [([Inline], [[Block]])]
    defs
        where shrinkDefinition :: ([Inline], [[Block]]) -> [([Inline], [[Block]])]
    shrinkDefinition ([Inline]
    ils, [[Block]]
    blksList) = [([Inline]
    ils', [[Block]]
    blksList) | [Inline]
    ils' <- [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils]
                                              [([Inline], [[Block]])]
    -> [([Inline], [[Block]])] -> [([Inline], [[Block]])]
    forall a. [a] -> [a] -> [a]
    ++ [([Inline]
    ils, [[Block]]
    blksList') | [[Block]]
    blksList' <- [[Block]] -> [[[Block]]]
    shrinkBlocksList [[Block]]
    blksList]
              shrinkDefinitionList :: [([Inline], [[Block]])] -> [[([Inline], [[Block]])]]
    shrinkDefinitionList (([Inline], [[Block]])
    x:[([Inline], [[Block]])]
    xs) = [[([Inline], [[Block]])]
    xs]
                                         [[([Inline], [[Block]])]]
    -> [[([Inline], [[Block]])]] -> [[([Inline], [[Block]])]]
    forall a. [a] -> [a] -> [a]
    ++ [([Inline], [[Block]])
    x'([Inline], [[Block]])
    -> [([Inline], [[Block]])] -> [([Inline], [[Block]])]
    forall a. a -> [a] -> [a]
    :[([Inline], [[Block]])]
    xs | ([Inline], [[Block]])
    x' <- ([Inline], [[Block]]) -> [([Inline], [[Block]])]
    shrinkDefinition ([Inline], [[Block]])
    x]
                                         [[([Inline], [[Block]])]]
    -> [[([Inline], [[Block]])]] -> [[([Inline], [[Block]])]]
    forall a. [a] -> [a] -> [a]
    ++ [([Inline], [[Block]])
    x([Inline], [[Block]])
    -> [([Inline], [[Block]])] -> [([Inline], [[Block]])]
    forall a. a -> [a] -> [a]
    :[([Inline], [[Block]])]
    xs' | [([Inline], [[Block]])]
    xs' <- [([Inline], [[Block]])] -> [[([Inline], [[Block]])]]
    shrinkDefinitionList [([Inline], [[Block]])]
    xs]
              shrinkDefinitionList [] = []
      shrink (Header Int
    n Attr
    attr [Inline]
    ils) = (Int -> Attr -> [Inline] -> Block
    Header Int
    n Attr
    attr ([Inline] -> Block) -> [[Inline]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> [[Inline]]
    shrinkInlineList [Inline]
    ils)
                                [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++ ((Attr -> [Inline] -> Block) -> [Inline] -> Attr -> Block
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip (Int -> Attr -> [Inline] -> Block
    Header Int
    n) [Inline]
    ils (Attr -> Block) -> [Attr] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr -> [Attr]
    shrinkAttr Attr
    attr)
      shrink Block
    HorizontalRule = []
      shrink (Table Attr
    attr Caption
    capt [ColSpec]
    specs TableHead
    thead [TableBody]
    tbody TableFoot
    tfoot) =
        -- TODO: shrink number of columns
        [Attr
    -> Caption
    -> [ColSpec]
    -> TableHead
    -> [TableBody]
    -> TableFoot
    -> Block
    Table Attr
    attr' Caption
    capt [ColSpec]
    specs TableHead
    thead [TableBody]
    tbody TableFoot
    tfoot | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr
    -> Caption
    -> [ColSpec]
    -> TableHead
    -> [TableBody]
    -> TableFoot
    -> Block
    Table Attr
    attr Caption
    capt [ColSpec]
    specs TableHead
    thead' [TableBody]
    tbody TableFoot
    tfoot | TableHead
    thead' <- TableHead -> [TableHead]
    forall a. Arbitrary a => a -> [a]
    shrink TableHead
    thead] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr
    -> Caption
    -> [ColSpec]
    -> TableHead
    -> [TableBody]
    -> TableFoot
    -> Block
    Table Attr
    attr Caption
    capt [ColSpec]
    specs TableHead
    thead [TableBody]
    tbody' TableFoot
    tfoot | [TableBody]
    tbody' <- [TableBody] -> [[TableBody]]
    forall a. Arbitrary a => a -> [a]
    shrink [TableBody]
    tbody] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr
    -> Caption
    -> [ColSpec]
    -> TableHead
    -> [TableBody]
    -> TableFoot
    -> Block
    Table Attr
    attr Caption
    capt [ColSpec]
    specs TableHead
    thead [TableBody]
    tbody TableFoot
    tfoot' | TableFoot
    tfoot' <- TableFoot -> [TableFoot]
    forall a. Arbitrary a => a -> [a]
    shrink TableFoot
    tfoot] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr
    -> Caption
    -> [ColSpec]
    -> TableHead
    -> [TableBody]
    -> TableFoot
    -> Block
    Table Attr
    attr Caption
    capt' [ColSpec]
    specs TableHead
    thead [TableBody]
    tbody TableFoot
    tfoot | Caption
    capt' <- Caption -> [Caption]
    forall a. Arbitrary a => a -> [a]
    shrink Caption
    capt]
      shrink (Figure Attr
    attr Caption
    capt [Block]
    blks) =
        [Attr -> Caption -> [Block] -> Block
    Figure Attr
    attr Caption
    capt [Block]
    blks' | [Block]
    blks' <- [Block] -> [[Block]]
    shrinkBlockList [Block]
    blks] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr -> Caption -> [Block] -> Block
    Figure Attr
    attr Caption
    capt' [Block]
    blks | Caption
    capt' <- Caption -> [Caption]
    forall a. Arbitrary a => a -> [a]
    shrink Caption
    capt] [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++
        [Attr -> Caption -> [Block] -> Block
    Figure Attr
    attr' Caption
    capt [Block]
    blks | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr]
      shrink (Div Attr
    attr [Block]
    blks) = (Attr -> [Block] -> Block
    Div Attr
    attr ([Block] -> Block) -> [[Block]] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Block] -> [[Block]]
    shrinkBlockList [Block]
    blks)
                            [Block] -> [Block] -> [Block]
    forall a. [a] -> [a] -> [a]
    ++ ((Attr -> [Block] -> Block) -> [Block] -> Attr -> Block
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Attr -> [Block] -> Block
    Div [Block]
    blks (Attr -> Block) -> [Attr] -> [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr -> [Attr]
    shrinkAttr Attr
    attr)

    arbBlock :: Int -> Gen Block
    arbBlock :: Int -> Gen Block
    arbBlock Int
    n = [(Int, Gen Block)] -> Gen Block
    forall a. HasCallStack => [(Int, Gen a)] -> Gen a
    frequency ([(Int, Gen Block)] -> Gen Block)
    -> [(Int, Gen Block)] -> Gen Block
    forall a b. (a -> b) -> a -> b
    $ [ (Int
    10, [Inline] -> Block
    Plain ([Inline] -> Block) -> Gen [Inline] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                             , (Int
    15, [Inline] -> Block
    Para ([Inline] -> Block) -> Gen [Inline] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                             , (Int
    5,  Attr -> Text -> Block
    CodeBlock (Attr -> Text -> Block) -> Gen Attr -> Gen (Text -> Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen (Text -> Block) -> Gen Text -> Gen Block
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Text
    realString)
                             , (Int
    3,  [[Inline]] -> Block
    LineBlock ([[Inline]] -> Block) -> Gen [[Inline]] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                    ((:) ([Inline] -> [[Inline]] -> [[Inline]])
    -> Gen [Inline] -> Gen ([[Inline]] -> [[Inline]])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                      Int -> Gen [Inline]
    arbInlines ((Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    3) Gen ([[Inline]] -> [[Inline]]) -> Gen [[Inline]] -> Gen [[Inline]]
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
                                      [Int] -> (Int -> Gen [Inline]) -> Gen [[Inline]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    t a -> (a -> m b) -> m (t b)
    forM [Int
    1..((Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1) Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` Int
    3)] (Gen [Inline] -> Int -> Gen [Inline]
    forall a b. a -> b -> a
    const (Int -> Gen [Inline]
    arbInlines Int
    3))))
                             , (Int
    2,  [Block] -> Gen Block
    forall a. HasCallStack => [a] -> Gen a
    elements [ Format -> Text -> Block
    RawBlock (Text -> Format
    Format Text
    "html")
                                                Text
    "<div>\n*&amp;*\n</div>"
                                             , Format -> Text -> Block
    RawBlock (Text -> Format
    Format Text
    "latex")
                                                Text
    "\\begin[opt]{env}\nhi\n{\\end{env}"
                                             ])
                             , (Int
    5,  Int -> Attr -> [Inline] -> Block
    Header (Int -> Attr -> [Inline] -> Block)
    -> Gen Int -> Gen (Attr -> [Inline] -> Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    1 :: Int, Int
    6)
                                           Gen (Attr -> [Inline] -> Block)
    -> Gen Attr -> Gen ([Inline] -> Block)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Attr -> Gen Attr
    forall a. a -> Gen a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Attr
    nullAttr
                                           Gen ([Inline] -> Block) -> Gen [Inline] -> Gen Block
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))
                             , (Int
    2,  Block -> Gen Block
    forall a. a -> Gen a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Block
    HorizontalRule)
                             ] [(Int, Gen Block)] -> [(Int, Gen Block)] -> [(Int, Gen Block)]
    forall a. [a] -> [a] -> [a]
    ++ [(Int, Gen Block)
    x | Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    0, (Int, Gen Block)
    x <- [(Int, Gen Block)]
    nesters]
       where nesters :: [(Int, Gen Block)]
    nesters = [ (Int
    5, [Block] -> Block
    BlockQuote ([Block] -> Block) -> Gen [Block] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       , (Int
    5, ListAttributes -> [[Block]] -> Block
    OrderedList (ListAttributes -> [[Block]] -> Block)
    -> Gen ListAttributes -> Gen ([[Block]] -> Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ((,,) (Int -> ListNumberStyle -> ListNumberDelim -> ListAttributes)
    -> Gen Int
    -> Gen (ListNumberStyle -> ListNumberDelim -> ListAttributes)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Gen Int
    forall a. Arbitrary a => Gen a
    arbitrary Gen Int -> (Int -> Bool) -> Gen Int
    forall a. Gen a -> (a -> Bool) -> Gen a
    `suchThat` (Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    0))
                                                    Gen (ListNumberStyle -> ListNumberDelim -> ListAttributes)
    -> Gen ListNumberStyle -> Gen (ListNumberDelim -> ListAttributes)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen ListNumberStyle
    forall a. Arbitrary a => Gen a
    arbitrary
                                                    Gen (ListNumberDelim -> ListAttributes)
    -> Gen ListNumberDelim -> Gen ListAttributes
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen ListNumberDelim
    forall a. Arbitrary a => Gen a
    arbitrary)
                                          Gen ([[Block]] -> Block) -> Gen [[Block]] -> Gen Block
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen [Block] -> Gen [[Block]]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]) -> Gen Block -> Gen [Block]
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       , (Int
    5, [[Block]] -> Block
    BulletList ([[Block]] -> Block) -> Gen [[Block]] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen [Block] -> Gen [[Block]]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]) -> Gen Block -> Gen [Block]
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       , (Int
    5, [([Inline], [[Block]])] -> Block
    DefinitionList ([([Inline], [[Block]])] -> Block)
    -> Gen [([Inline], [[Block]])] -> Gen Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen ([Inline], [[Block]]) -> Gen [([Inline], [[Block]])]
    forall a. Gen a -> Gen [a]
    listOf1 ((,) ([Inline] -> [[Block]] -> ([Inline], [[Block]]))
    -> Gen [Inline] -> Gen ([[Block]] -> ([Inline], [[Block]]))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Gen [Inline]
    arbInlines (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)
                                                              Gen ([[Block]] -> ([Inline], [[Block]]))
    -> Gen [[Block]] -> Gen ([Inline], [[Block]])
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen [Block] -> Gen [[Block]]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Gen Block -> Gen [Block]) -> Gen Block -> Gen [Block]
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1))))
                       , (Int
    5, Attr -> [Block] -> Block
    Div (Attr -> [Block] -> Block) -> Gen Attr -> Gen ([Block] -> Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr Gen ([Block] -> Block) -> Gen [Block] -> Gen Block
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       , (Int
    2, do cs <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    1 :: Int, Int
    6)
                                bs <- choose (0 :: Int, 2)
                                Table <$> arbAttr
                                      <*> arbitrary
                                      <*> vectorOf cs ((,) <$> arbitrary
                                                           <*> elements [ ColWidthDefault
                                                                        , ColWidth (1/3)
                                                                        , ColWidth 0.25 ])
                                      <*> arbTableHead (n-1)
                                      <*> vectorOf bs (arbTableBody (n-1))
                                      <*> arbTableFoot (n-1))
                       , (Int
    2, Attr -> Caption -> [Block] -> Block
    Figure (Attr -> Caption -> [Block] -> Block)
    -> Gen Attr -> Gen (Caption -> [Block] -> Block)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr
                                    Gen (Caption -> [Block] -> Block)
    -> Gen Caption -> Gen ([Block] -> Block)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Caption
    forall a. Arbitrary a => Gen a
    arbitrary
                                    Gen ([Block] -> Block) -> Gen [Block] -> Gen Block
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf1 (Int -> Gen Block
    arbBlock (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1)))
                       ]

    arbRow :: Int -> Gen Row
    arbRow :: Int -> Gen Row
    arbRow Int
    n = do
      cs <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0, Int
    5)
      Row <$> arbAttr <*> vectorOf cs (arbCell n)

    arbTableHead :: Int -> Gen TableHead
    arbTableHead :: Int -> Gen TableHead
    arbTableHead Int
    n = do
      rs <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0, Int
    5)
      TableHead <$> arbAttr <*> vectorOf rs (arbRow n)

    arbTableBody :: Int -> Gen TableBody
    arbTableBody :: Int -> Gen TableBody
    arbTableBody Int
    n = do
      hrs <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    2)
      rs <- choose (0, 5)
      rhc <- choose (0, 5)
      TableBody <$> arbAttr
                <*> pure (RowHeadColumns rhc)
                <*> vectorOf hrs (arbRow n)
                <*> vectorOf rs (arbRow n)

    arbTableFoot :: Int -> Gen TableFoot
    arbTableFoot :: Int -> Gen TableFoot
    arbTableFoot Int
    n = do
        rs <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0, Int
    5)
        TableFoot <$> arbAttr <*> vectorOf rs (arbRow n)

    arbCell :: Int -> Gen Cell
    arbCell :: Int -> Gen Cell
    arbCell Int
    n = Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
    Cell (Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell)
    -> Gen Attr
    -> Gen (Alignment -> RowSpan -> ColSpan -> [Block] -> Cell)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Attr
    arbAttr
                     Gen (Alignment -> RowSpan -> ColSpan -> [Block] -> Cell)
    -> Gen Alignment -> Gen (RowSpan -> ColSpan -> [Block] -> Cell)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Alignment
    forall a. Arbitrary a => Gen a
    arbitrary
                     Gen (RowSpan -> ColSpan -> [Block] -> Cell)
    -> Gen RowSpan -> Gen (ColSpan -> [Block] -> Cell)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Int -> RowSpan
    RowSpan (Int -> RowSpan) -> Gen Int -> Gen RowSpan
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    1 :: Int, Int
    2))
                     Gen (ColSpan -> [Block] -> Cell)
    -> Gen ColSpan -> Gen ([Block] -> Cell)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Int -> ColSpan
    ColSpan (Int -> ColSpan) -> Gen Int -> Gen ColSpan
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    1 :: Int, Int
    2))
                     Gen ([Block] -> Cell) -> Gen [Block] -> Gen Cell
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Block -> Gen [Block]
    forall a. Gen a -> Gen [a]
    listOf (Int -> Gen Block
    arbBlock Int
    n)

    instance Arbitrary Pandoc where
            arbitrary :: Gen Pandoc
    arbitrary = Int -> Gen Pandoc -> Gen Pandoc
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    8 (Meta -> [Block] -> Pandoc
    Pandoc (Meta -> [Block] -> Pandoc) -> Gen Meta -> Gen ([Block] -> Pandoc)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Meta
    forall a. Arbitrary a => Gen a
    arbitrary Gen ([Block] -> Pandoc) -> Gen [Block] -> Gen Pandoc
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen [Block]
    forall a. Arbitrary a => Gen a
    arbitrary)

    instance Arbitrary CitationMode where
            arbitrary :: Gen CitationMode
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    2)
                   case x of
                       Int
    0 -> CitationMode -> Gen CitationMode
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CitationMode
    AuthorInText
                       Int
    1 -> CitationMode -> Gen CitationMode
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CitationMode
    SuppressAuthor
                       Int
    2 -> CitationMode -> Gen CitationMode
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return CitationMode
    NormalCitation
                       Int
    _ -> String -> Gen CitationMode
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"

    instance Arbitrary Citation where
            arbitrary :: Gen Citation
    arbitrary
              = Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation (Text
     -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation)
    -> Gen Text
    -> Gen
         ([Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (String -> Text) -> Gen String -> Gen Text
    forall a b. (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap String -> Text
    T.pack (Gen Char -> Gen String
    forall a. Gen a -> Gen [a]
    listOf (Gen Char -> Gen String) -> Gen Char -> Gen String
    forall a b. (a -> b) -> a -> b
    $ String -> Gen Char
    forall a. HasCallStack => [a] -> Gen a
    elements (String -> Gen Char) -> String -> Gen Char
    forall a b. (a -> b) -> a -> b
    $ [Char
    'a'..Char
    'z'] String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ [Char
    '0'..Char
    '9'] String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ [Char
    '_'])
                         Gen
      ([Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation)
    -> Gen [Inline]
    -> Gen ([Inline] -> CitationMode -> Int -> Int -> Citation)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines Int
    1
                         Gen ([Inline] -> CitationMode -> Int -> Int -> Citation)
    -> Gen [Inline] -> Gen (CitationMode -> Int -> Int -> Citation)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Int -> Gen [Inline]
    arbInlines Int
    1
                         Gen (CitationMode -> Int -> Int -> Citation)
    -> Gen CitationMode -> Gen (Int -> Int -> Citation)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen CitationMode
    forall a. Arbitrary a => Gen a
    arbitrary
                         Gen (Int -> Int -> Citation) -> Gen Int -> Gen (Int -> Citation)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Int
    forall a. Arbitrary a => Gen a
    arbitrary
                         Gen (Int -> Citation) -> Gen Int -> Gen Citation
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen Int
    forall a. Arbitrary a => Gen a
    arbitrary

    instance Arbitrary Row where
      arbitrary :: Gen Row
    arbitrary = Int -> Gen Row -> Gen Row
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen Row -> Gen Row) -> Gen Row -> Gen Row
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Row
    arbRow Int
    2
      shrink :: Row -> [Row]
    shrink (Row Attr
    attr [Cell]
    body)
        = [Attr -> [Cell] -> Row
    Row Attr
    attr' [Cell]
    body | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [Row] -> [Row] -> [Row]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> [Cell] -> Row
    Row Attr
    attr [Cell]
    body' | [Cell]
    body' <- [Cell] -> [[Cell]]
    forall a. Arbitrary a => a -> [a]
    shrink [Cell]
    body]

    instance Arbitrary TableHead where
      arbitrary :: Gen TableHead
    arbitrary = Int -> Gen TableHead -> Gen TableHead
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen TableHead -> Gen TableHead) -> Gen TableHead -> Gen TableHead
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen TableHead
    arbTableHead Int
    2
      shrink :: TableHead -> [TableHead]
    shrink (TableHead Attr
    attr [Row]
    body)
        = [Attr -> [Row] -> TableHead
    TableHead Attr
    attr' [Row]
    body | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [TableHead] -> [TableHead] -> [TableHead]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> [Row] -> TableHead
    TableHead Attr
    attr [Row]
    body' | [Row]
    body' <- [Row] -> [[Row]]
    forall a. Arbitrary a => a -> [a]
    shrink [Row]
    body]

    instance Arbitrary TableBody where
      arbitrary :: Gen TableBody
    arbitrary = Int -> Gen TableBody -> Gen TableBody
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen TableBody -> Gen TableBody) -> Gen TableBody -> Gen TableBody
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen TableBody
    arbTableBody Int
    2
      -- TODO: shrink rhc?
      shrink :: TableBody -> [TableBody]
    shrink (TableBody Attr
    attr RowHeadColumns
    rhc [Row]
    hd [Row]
    bd)
        = [Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
    TableBody Attr
    attr' RowHeadColumns
    rhc [Row]
    hd [Row]
    bd | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [TableBody] -> [TableBody] -> [TableBody]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
    TableBody Attr
    attr RowHeadColumns
    rhc [Row]
    hd' [Row]
    bd | [Row]
    hd' <- [Row] -> [[Row]]
    forall a. Arbitrary a => a -> [a]
    shrink [Row]
    hd] [TableBody] -> [TableBody] -> [TableBody]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
    TableBody Attr
    attr RowHeadColumns
    rhc [Row]
    hd [Row]
    bd' | [Row]
    bd' <- [Row] -> [[Row]]
    forall a. Arbitrary a => a -> [a]
    shrink [Row]
    bd]

    instance Arbitrary TableFoot where
      arbitrary :: Gen TableFoot
    arbitrary = Int -> Gen TableFoot -> Gen TableFoot
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen TableFoot -> Gen TableFoot) -> Gen TableFoot -> Gen TableFoot
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen TableFoot
    arbTableFoot Int
    2
      shrink :: TableFoot -> [TableFoot]
    shrink (TableFoot Attr
    attr [Row]
    body)
        = [Attr -> [Row] -> TableFoot
    TableFoot Attr
    attr' [Row]
    body | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [TableFoot] -> [TableFoot] -> [TableFoot]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> [Row] -> TableFoot
    TableFoot Attr
    attr [Row]
    body' | [Row]
    body' <- [Row] -> [[Row]]
    forall a. Arbitrary a => a -> [a]
    shrink [Row]
    body]

    instance Arbitrary Cell where
      arbitrary :: Gen Cell
    arbitrary = Int -> Gen Cell -> Gen Cell
    forall a. HasCallStack => Int -> Gen a -> Gen a
    resize Int
    3 (Gen Cell -> Gen Cell) -> Gen Cell -> Gen Cell
    forall a b. (a -> b) -> a -> b
    $ Int -> Gen Cell
    arbCell Int
    2
      shrink :: Cell -> [Cell]
    shrink (Cell Attr
    attr Alignment
    malign RowSpan
    h ColSpan
    w [Block]
    body)
        = [Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
    Cell Attr
    attr Alignment
    malign RowSpan
    h ColSpan
    w [Block]
    body' | [Block]
    body' <- [Block] -> [[Block]]
    shrinkBlockList [Block]
    body] [Cell] -> [Cell] -> [Cell]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
    Cell Attr
    attr' Alignment
    malign RowSpan
    h ColSpan
    w [Block]
    body | Attr
    attr' <- Attr -> [Attr]
    shrinkAttr Attr
    attr] [Cell] -> [Cell] -> [Cell]
    forall a. [a] -> [a] -> [a]
    ++
          [Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
    Cell Attr
    attr Alignment
    malign' RowSpan
    h ColSpan
    w [Block]
    body | Alignment
    malign' <- Alignment -> [Alignment]
    forall a. Arbitrary a => a -> [a]
    shrink Alignment
    malign]

    instance Arbitrary Caption where
      arbitrary :: Gen Caption
    arbitrary = Maybe [Inline] -> [Block] -> Caption
    Caption (Maybe [Inline] -> [Block] -> Caption)
    -> Gen (Maybe [Inline]) -> Gen ([Block] -> Caption)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen (Maybe [Inline])
    forall a. Arbitrary a => Gen a
    arbitrary Gen ([Block] -> Caption) -> Gen [Block] -> Gen Caption
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen [Block]
    forall a. Arbitrary a => Gen a
    arbitrary
      shrink :: Caption -> [Caption]
    shrink (Caption Maybe [Inline]
    mshort [Block]
    body)
        = [Maybe [Inline] -> [Block] -> Caption
    Caption Maybe [Inline]
    mshort' [Block]
    body | Maybe [Inline]
    mshort' <- Maybe [Inline] -> [Maybe [Inline]]
    forall a. Arbitrary a => a -> [a]
    shrink Maybe [Inline]
    mshort] [Caption] -> [Caption] -> [Caption]
    forall a. [a] -> [a] -> [a]
    ++
          [Maybe [Inline] -> [Block] -> Caption
    Caption Maybe [Inline]
    mshort [Block]
    body' | [Block]
    body' <- [Block] -> [[Block]]
    shrinkBlockList [Block]
    body]

    instance Arbitrary MathType where
            arbitrary :: Gen MathType
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    1)
                   case x of
                       Int
    0 -> MathType -> Gen MathType
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return MathType
    DisplayMath
                       Int
    1 -> MathType -> Gen MathType
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return MathType
    InlineMath
                       Int
    _ -> String -> Gen MathType
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"

    instance Arbitrary QuoteType where
            arbitrary :: Gen QuoteType
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    1)
                   case x of
                       Int
    0 -> QuoteType -> Gen QuoteType
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return QuoteType
    SingleQuote
                       Int
    1 -> QuoteType -> Gen QuoteType
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return QuoteType
    DoubleQuote
                       Int
    _ -> String -> Gen QuoteType
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"

    instance Arbitrary Meta where
            arbitrary :: Gen Meta
    arbitrary
              = do (x1 :: Inlines) <- Gen (Many Inline)
    forall a. Arbitrary a => Gen a
    arbitrary
                   (x2 :: [Inlines]) <- filter (not . null) <$> arbitrary
                   (x3 :: Inlines) <- arbitrary
                   return $ setMeta "title" x1
                          $ setMeta "author" x2
                          $ setMeta "date" x3
                            nullMeta

    instance Arbitrary Alignment where
            arbitrary :: Gen Alignment
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    3)
                   case x of
                       Int
    0 -> Alignment -> Gen Alignment
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Alignment
    AlignLeft
                       Int
    1 -> Alignment -> Gen Alignment
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Alignment
    AlignRight
                       Int
    2 -> Alignment -> Gen Alignment
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Alignment
    AlignCenter
                       Int
    3 -> Alignment -> Gen Alignment
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Alignment
    AlignDefault
                       Int
    _ -> String -> Gen Alignment
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"

    instance Arbitrary ListNumberStyle where
            arbitrary :: Gen ListNumberStyle
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    6)
                   case x of
                       Int
    0 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    DefaultStyle
                       Int
    1 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    Example
                       Int
    2 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    Decimal
                       Int
    3 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    LowerRoman
                       Int
    4 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    UpperRoman
                       Int
    5 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    LowerAlpha
                       Int
    6 -> ListNumberStyle -> Gen ListNumberStyle
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberStyle
    UpperAlpha
                       Int
    _ -> String -> Gen ListNumberStyle
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"

    instance Arbitrary ListNumberDelim where
            arbitrary :: Gen ListNumberDelim
    arbitrary
              = do x <- (Int, Int) -> Gen Int
    forall a. Random a => (a, a) -> Gen a
    choose (Int
    0 :: Int, Int
    3)
                   case x of
                       Int
    0 -> ListNumberDelim -> Gen ListNumberDelim
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberDelim
    DefaultDelim
                       Int
    1 -> ListNumberDelim -> Gen ListNumberDelim
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberDelim
    Period
                       Int
    2 -> ListNumberDelim -> Gen ListNumberDelim
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberDelim
    OneParen
                       Int
    3 -> ListNumberDelim -> Gen ListNumberDelim
    forall a. a -> Gen a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ListNumberDelim
    TwoParens
                       Int
    _ -> String -> Gen ListNumberDelim
    forall a. HasCallStack => String -> a
    error String
    "FATAL ERROR: Arbitrary instance, logic bug"