{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances, ScopedTypeVariables, OverloadedStrings #-}
module Text.Pandoc.Arbitrary ()
where
import Test.QuickCheck
import Control.Applicative (Applicative ((<*>), pure), (<$>))
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 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ forall a. Int -> Gen a -> Gen a
resize Int
8 forall a b. (a -> b) -> a -> b
$ forall a. Gen a -> Gen [a]
listOf forall a b. (a -> b) -> a -> b
$ forall a. [(Int, Gen a)] -> Gen a
frequency [ (Int
9, forall a. [a] -> Gen a
elements [Char
' '..Char
'\127'])
, (Int
1, forall a. [a] -> Gen a
elements [Char
'\128'..Char
'\9999']) ]
shrinkText :: Text -> [Text]
shrinkText :: Text -> [Text]
shrinkText Text
xs = String -> Text
T.pack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink (Text -> String
T.unpack Text
xs)
shrinkText2 :: (Text, Text) -> [(Text, Text)]
shrinkText2 :: (Text, Text) -> [(Text, Text)]
shrinkText2 = 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
Text
id' <- forall a. [a] -> Gen a
elements [Text
"",Text
"loc"]
[Text]
classes' <- forall a. [a] -> Gen a
elements [[],[Text
"haskell"],[Text
"c",Text
"numberLines"]]
[(Text, Text)]
keyvals <- forall a. [a] -> Gen a
elements [[],[(Text
"start",Text
"22")],[(Text
"a",Text
"11"),(Text
"b_2",Text
"a b c")]]
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
id',[Text]
classes',[(Text, Text)]
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' <- forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
liftShrink Text -> [Text]
shrinkText [Text]
b,
[(Text, Text)]
c' <- 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 = (forall a. [a] -> Many a
fromList :: [Inline] -> Inlines) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary
shrink :: Many Inline -> [Many Inline]
shrink = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. [a] -> Many a
fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [a] -> [a]
(++) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Inline] -> [[Inline]]
flattenShrinkInlines) forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' forall a. [a] -> [a] -> [a]
++ [Inline]
xs | Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Inline]
x')] forall a. [a] -> [a] -> [a]
++ [Inline
xforall 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 = (forall a. [a] -> Many a
fromList :: [Block] -> Blocks) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary
shrink :: Many Block -> [Many Block]
shrink = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. [a] -> Many a
fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [a] -> [a]
(++) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Block] -> [[Block]]
flattenShrinkBlocks) forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' forall a. [a] -> [a] -> [a]
++ [Block]
xs | Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Block]
x')] forall a. [a] -> [a] -> [a]
++ [Block
xforall 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) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Block]]
blksList
flattenBlock (BulletList [[Block]]
blksList) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Block]]
blksList
flattenBlock (DefinitionList [([Inline], [[Block]])]
defs) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Inline] -> Block
Para [Inline]
ilsforall a. a -> [a] -> [a]
: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 forall a. Semigroup a => a -> a -> a
<>
TableHead -> [Block]
flattenTableHead TableHead
hd forall a. Semigroup a => a -> a -> a
<>
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap TableBody -> [Block]
flattenTableBody [TableBody]
bd forall a. Semigroup a => a -> a -> a
<>
TableFoot -> [Block]
flattenTableFoot TableFoot
ft
flattenBlock (Figure Attr
_ Caption
capt [Block]
blks) = Caption -> [Block]
flattenCaption Caption
capt 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 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 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 = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Row -> [Block]
flattenRow
flattenRow :: Row -> [Block]
flattenRow (Row Attr
_ [Cell]
body) = 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 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Many a -> [a]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Arbitrary a => a -> [a]
shrink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Many a
fromList
shrinkInlinesList :: [[Inline]] -> [[[Inline]]]
shrinkInlinesList :: [[Inline]] -> [[[Inline]]]
shrinkInlinesList = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Many a -> [a]
toList) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Arbitrary a => a -> [a]
shrink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. [a] -> Many a
fromList
shrinkBlockList :: [Block] -> [[Block]]
shrinkBlockList :: [Block] -> [[Block]]
shrinkBlockList = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Many a -> [a]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Arbitrary a => a -> [a]
shrink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Many a
fromList
shrinkBlocksList :: [[Block]] -> [[[Block]]]
shrinkBlocksList :: [[Block]] -> [[[Block]]]
shrinkBlocksList = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Many a -> [a]
toList) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Arbitrary a => a -> [a]
shrink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. [a] -> Many a
fromList
instance Arbitrary Inline where
arbitrary :: Gen Inline
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 forall a b. (a -> b) -> a -> b
$ Int -> Gen Inline
arbInline Int
2
shrink :: Inline -> [Inline]
shrink (Str Text
s) = Text -> Inline
Str forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
shrinkText Text
s
shrink (Emph [Inline]
ils) = [Inline] -> Inline
Emph forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Underline [Inline]
ils) = [Inline] -> Inline
Underline forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Strong [Inline]
ils) = [Inline] -> Inline
Strong forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Strikeout [Inline]
ils) = [Inline] -> Inline
Strikeout forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Superscript [Inline]
ils) = [Inline] -> Inline
Superscript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Subscript [Inline]
ils) = [Inline] -> Inline
Subscript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (SmallCaps [Inline]
ils) = [Inline] -> Inline
SmallCaps 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 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip [Citation] -> [Inline] -> Inline
Cite [Inline]
ils forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink [Citation]
cits)
shrink (Code Attr
attr Text
s) = (Attr -> Text -> Inline
Code Attr
attr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
shrinkText Text
s)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip Attr -> Text -> Inline
Code Text
s 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 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 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]
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]
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]
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]
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 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink [Inline]
s)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip Attr -> [Inline] -> Inline
Span [Inline]
s 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 = forall a. Gen a -> Gen [a]
listOf1 (Int -> Gen Inline
arbInline Int
n) forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (Bool -> Bool
not 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
startsWithSpace [Inline]
_ = Bool
False
arbInline :: Int -> Gen Inline
arbInline :: Int -> Gen Inline
arbInline Int
n = forall a. [(Int, Gen a)] -> Gen a
frequency forall a b. (a -> b) -> a -> b
$ [ (Int
60, Text -> Inline
Str forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
realString)
, (Int
40, forall (f :: * -> *) a. Applicative f => a -> f a
pure Inline
Space)
, (Int
10, forall (f :: * -> *) a. Applicative f => a -> f a
pure Inline
SoftBreak)
, (Int
10, forall (f :: * -> *) a. Applicative f => a -> f a
pure Inline
LineBreak)
, (Int
10, Attr -> Text -> Inline
Code forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
realString)
, (Int
5, forall a. [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}" ])
] forall a. [a] -> [a] -> [a]
++ [ (Int, Gen Inline)
x | Int
n 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
Underline forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
Strong forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
Strikeout forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
Superscript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
Subscript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, [Inline] -> Inline
SmallCaps forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, Attr -> [Inline] -> Inline
Span forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, QuoteType -> [Inline] -> Inline
Quoted forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
10, MathType -> Text -> Inline
Math forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
realString)
, (Int
10, Attr -> [Inline] -> (Text, Text) -> Inline
Link forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
realString forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
realString))
, (Int
10, Attr -> [Inline] -> (Text, Text) -> Inline
Image forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
realString forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
realString))
, (Int
2, [Citation] -> [Inline] -> Inline
Cite forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines Int
1)
, (Int
2, [Block] -> Inline
Note forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Int -> Gen a -> Gen a
resize Int
3 (forall a. Gen a -> Gen [a]
listOf1 forall a b. (a -> b) -> a -> b
$ Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
]
instance Arbitrary Block where
arbitrary :: Gen Block
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 forall a b. (a -> b) -> a -> b
$ Int -> Gen Block
arbBlock Int
2
shrink :: Block -> [Block]
shrink (Plain [Inline]
ils) = [Inline] -> Block
Plain forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (Para [Inline]
ils) = [Inline] -> Block
Para forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils
shrink (LineBlock [[Inline]]
lns) = [[Inline]] -> Block
LineBlock 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
shrinkText Text
s)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip Attr -> Text -> Block
CodeBlock Text
s 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
shrinkText Text
s
shrink (BlockQuote [Block]
blks) = [Block] -> Block
BlockQuote 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [[Block]] -> [[[Block]]]
shrinkBlocksList [[Block]]
blksList
shrink (BulletList [[Block]]
blksList) = [[Block]] -> Block
BulletList 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 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]
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]
forall a. [a] -> [a] -> [a]
++ [([Inline], [[Block]])
x'forall a. a -> [a] -> [a]
:[([Inline], [[Block]])]
xs | ([Inline], [[Block]])
x' <- ([Inline], [[Block]]) -> [([Inline], [[Block]])]
shrinkDefinition ([Inline], [[Block]])
x]
forall a. [a] -> [a] -> [a]
++ [([Inline], [[Block]])
xforall 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Inline] -> [[Inline]]
shrinkInlineList [Inline]
ils)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip (Int -> Attr -> [Inline] -> Block
Header Int
n) [Inline]
ils 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) =
[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] 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' <- forall a. Arbitrary a => a -> [a]
shrink TableHead
thead] 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' <- forall a. Arbitrary a => a -> [a]
shrink [TableBody]
tbody] 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' <- forall a. Arbitrary a => a -> [a]
shrink TableFoot
tfoot] 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' <- 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] forall a. [a] -> [a] -> [a]
++
[Attr -> Caption -> [Block] -> Block
Figure Attr
attr Caption
capt' [Block]
blks | Caption
capt' <- forall a. Arbitrary a => a -> [a]
shrink Caption
capt] 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Block] -> [[Block]]
shrinkBlockList [Block]
blks)
forall a. [a] -> [a] -> [a]
++ (forall a b c. (a -> b -> c) -> b -> a -> c
flip Attr -> [Block] -> Block
Div [Block]
blks 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 = forall a. [(Int, Gen a)] -> Gen a
frequency forall a b. (a -> b) -> a -> b
$ [ (Int
10, [Inline] -> Block
Plain forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
15, [Inline] -> Block
Para forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
5, Attr -> Text -> Block
CodeBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
realString)
, (Int
3, [[Inline]] -> Block
LineBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
((:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Int -> Gen [Inline]
arbInlines ((Int
n forall a. Num a => a -> a -> a
- Int
1) forall a. Integral a => a -> a -> a
`mod` Int
3) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Int
1..((Int
n forall a. Num a => a -> a -> a
- Int
1) forall a. Integral a => a -> a -> a
`div` Int
3)] (forall a b. a -> b -> a
const (Int -> Gen [Inline]
arbInlines Int
3))))
, (Int
2, forall a. [a] -> Gen a
elements [ Format -> Text -> Block
RawBlock (Text -> Format
Format Text
"html")
Text
"<div>\n*&*\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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Random a => (a, a) -> Gen a
choose (Int
1 :: Int, Int
6)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Attr
nullAttr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
2, forall (f :: * -> *) a. Applicative f => a -> f a
pure Block
HorizontalRule)
] forall a. [a] -> [a] -> [a]
++ [(Int, Gen Block)
x | Int
n 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Gen a -> Gen [a]
listOf1 (Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
, (Int
5, ListAttributes -> [[Block]] -> Block
OrderedList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. Arbitrary a => Gen a
arbitrary forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (forall a. Ord a => a -> a -> Bool
> Int
0))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Gen a -> Gen [a]
listOf1 (forall a. Gen a -> Gen [a]
listOf1 forall a b. (a -> b) -> a -> b
$ Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
, (Int
5, [[Block]] -> Block
BulletList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Gen a -> Gen [a]
listOf1 (forall a. Gen a -> Gen [a]
listOf1 forall a b. (a -> b) -> a -> b
$ Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
, (Int
5, [([Inline], [[Block]])] -> Block
DefinitionList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Gen a -> Gen [a]
listOf1 ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen [Inline]
arbInlines (Int
nforall a. Num a => a -> a -> a
-Int
1)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Gen a -> Gen [a]
listOf1 (forall a. Gen a -> Gen [a]
listOf1 forall a b. (a -> b) -> a -> b
$ Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1))))
, (Int
5, Attr -> [Block] -> Block
Div forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Gen a -> Gen [a]
listOf1 (Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
, (Int
2, do Int
cs <- forall a. Random a => (a, a) -> Gen a
choose (Int
1 :: Int, Int
6)
Int
bs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
2)
Attr
-> Caption
-> [ColSpec]
-> TableHead
-> [TableBody]
-> TableFoot
-> Block
Table forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
cs ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. [a] -> Gen a
elements [ ColWidth
ColWidthDefault
, Double -> ColWidth
ColWidth (Double
1forall a. Fractional a => a -> a -> a
/Double
3)
, Double -> ColWidth
ColWidth Double
0.25 ])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen TableHead
arbTableHead (Int
nforall a. Num a => a -> a -> a
-Int
1)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
bs (Int -> Gen TableBody
arbTableBody (Int
nforall a. Num a => a -> a -> a
-Int
1))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen TableFoot
arbTableFoot (Int
nforall a. Num a => a -> a -> a
-Int
1))
, (Int
2, Attr -> Caption -> [Block] -> Block
Figure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Gen a -> Gen [a]
listOf1 (Int -> Gen Block
arbBlock (Int
nforall a. Num a => a -> a -> a
-Int
1)))
]
arbRow :: Int -> Gen Row
arbRow :: Int -> Gen Row
arbRow Int
n = do
Int
cs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
5)
Attr -> [Cell] -> Row
Row forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
cs (Int -> Gen Cell
arbCell Int
n)
arbTableHead :: Int -> Gen TableHead
arbTableHead :: Int -> Gen TableHead
arbTableHead Int
n = do
Int
rs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
5)
Attr -> [Row] -> TableHead
TableHead forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
rs (Int -> Gen Row
arbRow Int
n)
arbTableBody :: Int -> Gen TableBody
arbTableBody :: Int -> Gen TableBody
arbTableBody Int
n = do
Int
hrs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
2)
Int
rs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
5)
Int
rhc <- forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
5)
Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> RowHeadColumns
RowHeadColumns Int
rhc)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
hrs (Int -> Gen Row
arbRow Int
n)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
rs (Int -> Gen Row
arbRow Int
n)
arbTableFoot :: Int -> Gen TableFoot
Int
n = do
Int
rs <- forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
5)
Attr -> [Row] -> TableFoot
TableFoot forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Int -> Gen a -> Gen [a]
vectorOf Int
rs (Int -> Gen Row
arbRow Int
n)
arbCell :: Int -> Gen Cell
arbCell :: Int -> Gen Cell
arbCell Int
n = Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Attr
arbAttr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Int -> RowSpan
RowSpan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Random a => (a, a) -> Gen a
choose (Int
1 :: Int, Int
2))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Int -> ColSpan
ColSpan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Random a => (a, a) -> Gen a
choose (Int
1 :: Int, Int
2))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Gen a -> Gen [a]
listOf (Int -> Gen Block
arbBlock Int
n)
instance Arbitrary Pandoc where
arbitrary :: Gen Pandoc
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
8 (Meta -> [Block] -> Pandoc
Pandoc forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary)
instance Arbitrary CitationMode where
arbitrary :: Gen CitationMode
arbitrary
= do Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
2)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return CitationMode
AuthorInText
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return CitationMode
SuppressAuthor
Int
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return CitationMode
NormalCitation
Int
_ -> 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack (forall a. Gen a -> Gen [a]
listOf forall a b. (a -> b) -> a -> b
$ forall a. [a] -> Gen a
elements forall a b. (a -> b) -> a -> b
$ [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9'] forall a. [a] -> [a] -> [a]
++ [Char
'_'])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines Int
1
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Gen [Inline]
arbInlines Int
1
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary
instance Arbitrary Row where
arbitrary :: Gen Row
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 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] forall a. [a] -> [a] -> [a]
++
[Attr -> [Cell] -> Row
Row Attr
attr [Cell]
body' | [Cell]
body' <- forall a. Arbitrary a => a -> [a]
shrink [Cell]
body]
instance Arbitrary TableHead where
arbitrary :: Gen TableHead
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 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] forall a. [a] -> [a] -> [a]
++
[Attr -> [Row] -> TableHead
TableHead Attr
attr [Row]
body' | [Row]
body' <- forall a. Arbitrary a => a -> [a]
shrink [Row]
body]
instance Arbitrary TableBody where
arbitrary :: Gen TableBody
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 forall a b. (a -> b) -> a -> b
$ Int -> Gen TableBody
arbTableBody Int
2
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] forall a. [a] -> [a] -> [a]
++
[Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
attr RowHeadColumns
rhc [Row]
hd' [Row]
bd | [Row]
hd' <- forall a. Arbitrary a => a -> [a]
shrink [Row]
hd] forall a. [a] -> [a] -> [a]
++
[Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
attr RowHeadColumns
rhc [Row]
hd [Row]
bd' | [Row]
bd' <- forall a. Arbitrary a => a -> [a]
shrink [Row]
bd]
instance Arbitrary TableFoot where
arbitrary :: Gen TableFoot
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 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] forall a. [a] -> [a] -> [a]
++
[Attr -> [Row] -> TableFoot
TableFoot Attr
attr [Row]
body' | [Row]
body' <- forall a. Arbitrary a => a -> [a]
shrink [Row]
body]
instance Arbitrary Cell where
arbitrary :: Gen Cell
arbitrary = forall a. Int -> Gen a -> Gen a
resize Int
3 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] 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] forall a. [a] -> [a] -> [a]
++
[Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
malign' RowSpan
h ColSpan
w [Block]
body | Alignment
malign' <- forall a. Arbitrary a => a -> [a]
shrink Alignment
malign]
instance Arbitrary Caption where
arbitrary :: Gen Caption
arbitrary = Maybe [Inline] -> [Block] -> Caption
Caption forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> 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' <- forall a. Arbitrary a => a -> [a]
shrink Maybe [Inline]
mshort] 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 Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
1)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return MathType
DisplayMath
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return MathType
InlineMath
Int
_ -> forall a. HasCallStack => String -> a
error String
"FATAL ERROR: Arbitrary instance, logic bug"
instance Arbitrary QuoteType where
arbitrary :: Gen QuoteType
arbitrary
= do Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
1)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return QuoteType
SingleQuote
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return QuoteType
DoubleQuote
Int
_ -> forall a. HasCallStack => String -> a
error String
"FATAL ERROR: Arbitrary instance, logic bug"
instance Arbitrary Meta where
arbitrary :: Gen Meta
arbitrary
= do (Many Inline
x1 :: Inlines) <- forall a. Arbitrary a => Gen a
arbitrary
([Many Inline]
x2 :: [Inlines]) <- forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary
(Many Inline
x3 :: Inlines) <- forall a. Arbitrary a => Gen a
arbitrary
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
"title" Many Inline
x1
forall a b. (a -> b) -> a -> b
$ forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
"author" [Many Inline]
x2
forall a b. (a -> b) -> a -> b
$ forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
"date" Many Inline
x3
Meta
nullMeta
instance Arbitrary Alignment where
arbitrary :: Gen Alignment
arbitrary
= do Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
3)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Alignment
AlignLeft
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return Alignment
AlignRight
Int
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return Alignment
AlignCenter
Int
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return Alignment
AlignDefault
Int
_ -> forall a. HasCallStack => String -> a
error String
"FATAL ERROR: Arbitrary instance, logic bug"
instance Arbitrary ListNumberStyle where
arbitrary :: Gen ListNumberStyle
arbitrary
= do Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
6)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
DefaultStyle
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
Example
Int
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
Decimal
Int
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
LowerRoman
Int
4 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
UpperRoman
Int
5 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
LowerAlpha
Int
6 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberStyle
UpperAlpha
Int
_ -> forall a. HasCallStack => String -> a
error String
"FATAL ERROR: Arbitrary instance, logic bug"
instance Arbitrary ListNumberDelim where
arbitrary :: Gen ListNumberDelim
arbitrary
= do Int
x <- forall a. Random a => (a, a) -> Gen a
choose (Int
0 :: Int, Int
3)
case Int
x of
Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberDelim
DefaultDelim
Int
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberDelim
Period
Int
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberDelim
OneParen
Int
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return ListNumberDelim
TwoParens
Int
_ -> forall a. HasCallStack => String -> a
error String
"FATAL ERROR: Arbitrary instance, logic bug"