packages feed

pandoc-types 1.17.5.1 → 1.17.5.2

raw patch · 3 files changed

+133/−5 lines, 3 filesdep ~QuickCheckdep ~criteriondep ~deepseq-genericsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: QuickCheck, criterion, deepseq-generics

API changes (from Hackage documentation)

- Text.Pandoc.Builder: instance Data.Semigroup.Semigroup (Text.Pandoc.Builder.Many Text.Pandoc.Definition.Block)
- Text.Pandoc.Builder: instance Data.Semigroup.Semigroup Text.Pandoc.Builder.Inlines
- Text.Pandoc.Definition: instance Data.Semigroup.Semigroup Text.Pandoc.Definition.Meta
- Text.Pandoc.Definition: instance Data.Semigroup.Semigroup Text.Pandoc.Definition.Pandoc
+ Text.Pandoc.Builder: instance GHC.Base.Semigroup (Text.Pandoc.Builder.Many Text.Pandoc.Definition.Block)
+ Text.Pandoc.Builder: instance GHC.Base.Semigroup Text.Pandoc.Builder.Inlines
+ Text.Pandoc.Definition: instance GHC.Base.Semigroup Text.Pandoc.Definition.Meta
+ Text.Pandoc.Definition: instance GHC.Base.Semigroup Text.Pandoc.Definition.Pandoc

Files

Text/Pandoc/Arbitrary.hs view
@@ -22,12 +22,95 @@  instance Arbitrary Inlines where   arbitrary = (fromList :: [Inline] -> Inlines) <$> arbitrary+  shrink = fmap fromList . ((++) <$> shrink <*> flattenShrinkInlines) . toList+    where flattenShrinkInlines (x:xs) =+            let x' = flattenInline x+            in (if null x' then [] else [x' ++ xs]) ++ [x:xs' | xs' <- flattenShrinkInlines xs]+          flattenShrinkInlines [] = []+          flattenInline :: Inline -> [Inline]+          flattenInline (Str _) = []+          flattenInline (Emph ils) = ils+          flattenInline (Strong ils) = ils+          flattenInline (Strikeout ils) = ils+          flattenInline (Superscript ils) = ils+          flattenInline (Subscript ils) = ils+          flattenInline (SmallCaps ils) = ils+          flattenInline (Quoted _ ils) = ils+          flattenInline (Cite _ ils) = ils+          flattenInline Code{} = []+          flattenInline Space = []+          flattenInline SoftBreak = []+          flattenInline LineBreak = []+          flattenInline Math{} = []+          flattenInline RawInline{} = []+          flattenInline (Link _ ils _) = ils+          flattenInline (Image _ ils _) = ils+          flattenInline Note{} = []+          flattenInline (Span _ ils) = ils  instance Arbitrary Blocks where   arbitrary = (fromList :: [Block] -> Blocks) <$> arbitrary+  shrink = fmap fromList . ((++) <$> shrink <*> flattenShrinkBlocks) . toList+    where flattenShrinkBlocks (x:xs) =+            let x' = flattenBlock x+            in (if null x' then [] else [x' ++ xs]) ++ [x:xs' | xs' <- flattenShrinkBlocks xs]+          flattenShrinkBlocks [] = []+          flattenBlock :: Block -> [Block]+          flattenBlock Plain{} = []+          flattenBlock Para{} = []+          flattenBlock (LineBlock lns) = [Para x | x <- lns]+          flattenBlock CodeBlock{} = []+          flattenBlock RawBlock{} = []+          flattenBlock (BlockQuote blks) = blks+          flattenBlock (OrderedList _ blksList) = concat blksList+          flattenBlock (BulletList blksList) = concat blksList+          flattenBlock (DefinitionList defs) = concat [Para ils:concat blks | (ils, blks) <- defs]+          flattenBlock (Header _ _ ils) = [Para ils]+          flattenBlock HorizontalRule = []+          flattenBlock (Table caption _ _ cells rows) = Para caption : concat (concat $ cells:rows)+          flattenBlock (Div _ blks) = blks+          flattenBlock Null = [] +shrinkInlineList :: [Inline] -> [[Inline]]+shrinkInlineList = fmap toList . shrink . fromList++shrinkInlinesList :: [[Inline]] -> [[[Inline]]]+shrinkInlinesList = fmap (fmap toList) . shrink . fmap fromList++shrinkBlockList :: [Block] -> [[Block]]+shrinkBlockList = fmap toList . shrink . fromList++shrinkBlocksList :: [[Block]] -> [[[Block]]]+shrinkBlocksList = fmap (fmap toList) . shrink . fmap fromList+ instance Arbitrary Inline where   arbitrary = resize 3 $ arbInline 2+  shrink (Str s) = Str <$> shrink s+  shrink (Emph ils) = Emph <$> shrinkInlineList ils+  shrink (Strong ils) = Strong <$> shrinkInlineList ils+  shrink (Strikeout ils) = Strikeout <$> shrinkInlineList ils+  shrink (Superscript ils) = Superscript <$> shrinkInlineList ils+  shrink (Subscript ils) = Subscript <$> shrinkInlineList ils+  shrink (SmallCaps ils) = SmallCaps <$> shrinkInlineList ils+  shrink (Quoted qtype ils) = Quoted qtype <$> shrinkInlineList ils+  shrink (Cite cits ils) = (Cite cits <$> shrinkInlineList ils)+                        ++ (flip Cite ils <$> shrink cits)+  shrink (Code attr s) = (Code attr <$> shrink s)+                      ++ (flip Code s <$> shrink attr)+  shrink Space = []+  shrink SoftBreak = []+  shrink LineBreak = []+  shrink (Math mtype s) = Math mtype <$> shrink s+  shrink (RawInline fmt s) = RawInline fmt <$> shrink s+  shrink (Link attr ils target) = [Link attr ils' target | ils' <- shrinkInlineList ils]+                               ++ [Link attr ils target' | target' <- shrink target]+                               ++ [Link attr' ils target | attr' <- shrink attr]+  shrink (Image attr ils target) = [Image attr ils' target | ils' <- shrinkInlineList ils]+                                ++ [Image attr ils target' | target' <- shrink target]+                                ++ [Image attr' ils target | attr' <- shrink attr]+  shrink (Note blks) = Note <$> shrinkBlockList blks+  shrink (Span attr s) = (Span attr <$> shrink s)+                      ++ (flip Span s <$> shrink attr)  arbInlines :: Int -> Gen [Inline] arbInlines n = listOf1 (arbInline n) `suchThat` (not . startsWithSpace)@@ -64,6 +147,46 @@  instance Arbitrary Block where   arbitrary = resize 3 $ arbBlock 2+  shrink (Plain ils) = Plain <$> shrinkInlineList ils+  shrink (Para ils) = Para <$> shrinkInlineList ils+  shrink (LineBlock lns) = LineBlock <$> shrinkInlinesList lns+  shrink (CodeBlock attr s) = (CodeBlock attr <$> shrink s)+                           ++ (flip CodeBlock s <$> shrink attr)+  shrink (RawBlock fmt s) = RawBlock fmt <$> shrink s+  shrink (BlockQuote blks) = BlockQuote <$> shrinkBlockList blks+  shrink (OrderedList listAttrs blksList) = OrderedList listAttrs <$> shrinkBlocksList blksList+  shrink (BulletList blksList) = BulletList <$> shrinkBlocksList blksList+  shrink (DefinitionList defs) = DefinitionList <$> shrinkDefinitionList defs+    where shrinkDefinition (ils, blksList) = [(ils', blksList) | ils' <- shrinkInlineList ils]+                                          ++ [(ils, blksList') | blksList' <- shrinkBlocksList blksList]+          shrinkDefinitionList (x:xs) = [xs]+                                     ++ [x':xs | x' <- shrinkDefinition x]+                                     ++ [x:xs' | xs' <- shrinkDefinitionList xs]+          shrinkDefinitionList [] = []+  shrink (Header n attr ils) = (Header n attr <$> shrinkInlineList ils)+                            ++ (flip (Header n) ils <$> shrink attr)+  shrink HorizontalRule = []+  shrink (Table caption aligns widths cells rows) =+    -- TODO: shrink number of columns+    -- Shrink header contents+    [Table caption aligns widths cells' rows | cells' <- shrinkRow cells] +++    -- Shrink number of rows and row contents+    [Table caption aligns widths cells rows' | rows' <- shrinkRows rows] +++    -- Shrink caption+    [Table caption' aligns widths cells rows | caption' <- shrinkInlineList caption]+    where -- Shrink row contents without reducing the number of columns+          shrinkRow :: [TableCell] -> [[TableCell]]+          shrinkRow (x:xs) = [x':xs | x' <- shrinkBlockList x]+                          ++ [x:xs' | xs' <- shrinkRow xs]+          shrinkRow [] = []+          shrinkRows :: [[TableCell]] -> [[[TableCell]]]+          shrinkRows (x:xs) = [xs] -- Shrink number of rows+                           ++ [x':xs | x' <- shrinkRow x] -- Shrink row contents+                           ++ [x:xs' | xs' <- shrinkRows xs]+          shrinkRows [] = []+  shrink (Div attr blks) = (Div attr <$> shrinkBlockList blks)+                        ++ (flip Div blks <$> shrink attr)+  shrink Null = []  arbBlock :: Int -> Gen Block arbBlock n = frequency $ [ (10, Plain <$> arbInlines (n-1))
changelog view
@@ -1,3 +1,8 @@+[1.17.5.2]++  * Bump upper bound for deepseq-generics, QuickCheck, criterion.+  * Implement QuickCheck shrinking for Inlines and Blocks (Alexander Krotov).+ [1.17.5.1]    * Declare the ToMetaValue instance for String as OVERLAPPING (#46).
pandoc-types.cabal view
@@ -1,5 +1,5 @@ Name:                pandoc-types-Version:             1.17.5.1+Version:             1.17.5.2 Synopsis:            Types for representing a structured document Description:         @Text.Pandoc.Definition@ defines the 'Pandoc' data                      structure, which is used by pandoc to represent@@ -53,11 +53,11 @@                      bytestring >= 0.9 && < 0.11,                      aeson >= 0.6.2 && < 1.5,                      transformers >= 0.2 && < 0.6,-                     QuickCheck >= 2+                     QuickCheck >= 2.4 && < 2.13   if !impl(ghc >= 8.0)     Build-depends:   semigroups == 0.18.*   if impl(ghc < 7.10)-    Build-depends:   deepseq-generics >= 0.1 && < 0.2+    Build-depends:   deepseq-generics >= 0.1 && < 0.3   else     Build-depends:   deepseq >= 1.4.1 && < 1.5   ghc-options:       -Wall@@ -75,7 +75,7 @@                        test-framework >= 0.3 && < 0.9,                        test-framework-hunit >= 0.2 && < 0.4,                        test-framework-quickcheck2 >= 0.2.9 && < 0.4,-                       QuickCheck >= 2.4 && < 2.12,+                       QuickCheck >= 2.4 && < 2.13,                        HUnit >= 1.2 && < 1.7,                        string-qq == 0.0.2   ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall -O2@@ -86,5 +86,5 @@   hs-source-dirs:  benchmark   build-depends:   pandoc-types,                    base >= 4.5 && < 5,-                   criterion >= 1.0 && < 1.5+                   criterion >= 1.0 && < 1.6   ghc-options:   -rtsopts -Wall -fno-warn-unused-do-bind -O2