packages feed

pro-abstract 0.1.0.0 → 0.1.1.0

raw patch · 10 files changed

+115/−6 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ ProAbstract.Datatypes: BlockTagContent_Fork :: Blocks ann -> BlockTagContent ann
+ ProAbstract.Datatypes: BlockTagContent_Plain :: PlainBlock ann -> BlockTagContent ann
+ ProAbstract.Datatypes: data BlockTagContent ann
+ ProAbstract.Structure: BlockTagContent_Fork :: Blocks ann -> BlockTagContent ann
+ ProAbstract.Structure: BlockTagContent_Plain :: PlainBlock ann -> BlockTagContent ann
+ ProAbstract.Structure: data BlockTagContent ann
+ ProAbstract.Types: data BlockTagContent ann

Files

+ changelog.txt view
@@ -0,0 +1,3 @@+v0.1.0.0 - Initial++v0.1.1.0 - Added the BlockTagContent type
library/pro-abstract/ProAbstract.hs view
@@ -27,7 +27,7 @@  Optics: -- 'tag' targets the tag at a node; it is either a prism or an affine traversal, depending on the node type.+- 'tag' targets the tag at a node; it is either a lens or an affine traversal, depending on the node type. - The 'allTags' traversal targets every tag at and below a node. - The 'allBlockTags' and 'allInlineTags' also target tags at or below a node, but are limited to tags at the block or inline level, respectively. - Since a tag has metadata, all of the optics for targeting parts of metadata (e.g. 'atSetting' and 'hasProperty') are also available on 'Tag' and on 'Tagged' nodes.@@ -37,7 +37,9 @@   - Pure: 'mapMaybeTags', 'mapMaybeBlockTags', 'mapMaybeInlineTags'   - Monadic: 'witherTags', 'witherBlockTags', 'witherInlineTags' +Example: @'mapMaybeTags' (preview (filtered \\x -> view 'name' x /= "comment"))@ is an endofunction that removes all nodes having a tag name of "comment". + === The Block level  /Block-level/ content is everything that appears below the document level and above the paragraph level.@@ -57,7 +59,7 @@  - /Paragraphs/ contain inline content. -    * 'Paragraph' = ('content' : 'Lines') × ('annotation' : 'Annotation')+    * 'Paragraph' = ('contents' : 'Line') × ('annotation' : 'Annotation')  Unenforced guideline: The 'Lines' of a 'Paragraph' should contain at least one 'Line'. @@ -74,7 +76,12 @@  Example: @'blockTag' % 'Optics.Core.filtered' (\x -> 'Optics.Core.view' 'name' x == "h1")@ is an affine fold that targets blocks with a tag name of "h1". +The BlockTag type can also be described as: +- 'BlockTag' = ('tag' :: 'Tag') × ('content' : 'BlockTagContent')+- 'BlockTagContent' = ('fork' : 'Blocks') ∪ ('plain' : 'PlainBlock')++ === The Inline level  /Inline-level/ content is everything below the paragraph level.@@ -115,7 +122,7 @@  Optics: -- 'metadata' targets the metadata of a node; it is either a prism or an affine traversal, depending on the node type.+- 'metadata' targets the metadata of a node; it is either a lens or an affine traversal, depending on the node type. - 'atSetting' and 'hasProperty' target specific parts of metadata by name. - The 'allMetadata' traversal targets every metadata at and under a node. @@ -134,6 +141,8 @@ | 'Document'            | 'Blocks'              | 'Block'               | +-----------------------+-----------------------+-----------------------+ | 'Blocks'              | —                     | 'Block'               |++-----------------------+-----------------------+-----------------------++| 'BlockTag'            | 'BlockTagContent'     | —                     | +-----------------------+-----------------------+-----------------------+ | 'Paragraph'           | 'Lines'               | 'Line'                | +-----------------------+-----------------------+-----------------------+
library/pro-abstract/ProAbstract/Datatypes.hs view
@@ -4,7 +4,7 @@       Document (..)      -- * Blocks-    , Block (..), Blocks (..)+    , Block (..), Blocks (..), BlockTagContent (..)      -- * Lines     , Inline (..), Line (..), Lines (..)
library/pro-abstract/ProAbstract/Structure.hs view
@@ -4,7 +4,7 @@       Document (..)      -- * Blocks-    , Block (..), paragraph, Blocks (..), BlockTag (..), blockTag+    , Block (..), paragraph, Blocks (..), BlockTag (..), blockTag, BlockTagContent (..)      -- * Paragraph     , Paragraph (..)@@ -29,6 +29,7 @@  import ProAbstract.Structure.Block import ProAbstract.Structure.BlockTag+import ProAbstract.Structure.BlockTagContent import ProAbstract.Structure.CanBePlain import ProAbstract.Structure.CanFork import ProAbstract.Structure.Document
library/pro-abstract/ProAbstract/Structure/BlockTag.hs view
@@ -3,8 +3,10 @@     ) where  import ProAbstract.Annotation+import ProAbstract.Content import ProAbstract.Metadata import ProAbstract.Structure.Block+import ProAbstract.Structure.BlockTagContent import ProAbstract.Structure.CanBePlain import ProAbstract.Structure.CanFork import ProAbstract.Structure.Fork@@ -19,11 +21,25 @@     BlockTagFork  (Tagged (Blocks ann))     -- ^ 'ProAbstract.fork'   | BlockTagPlain (Tagged (PlainBlock ann)) -- ^ 'ProAbstract.plain' +type instance Content (BlockTag ann) = BlockTagContent ann+ type instance Annotation (BlockTag ann) = ann  type instance Plain (BlockTag ann) = Tagged (PlainBlock ann)  type instance Fork (BlockTag ann) = Tagged (Blocks ann)++instance HasContent (BlockTag ann) (BlockTag ann) where+    content = lens f g+      where+        f = \case+            BlockTagFork x -> BlockTagContent_Fork $ view content x+            BlockTagPlain x -> BlockTagContent_Plain $ view content x+        g x = \case+            BlockTagContent_Fork c -> BlockTagFork $ TaggedBlocks t c+            BlockTagContent_Plain c -> BlockTagPlain $ TaggedPlainBlock t c+          where+            t = view tag x  instance CanFork (BlockTag ann) where     fork = prism' BlockTagFork \case{ BlockTagFork x -> Just x; _ -> Nothing }
+ library/pro-abstract/ProAbstract/Structure/BlockTagContent.hs view
@@ -0,0 +1,70 @@+module ProAbstract.Structure.BlockTagContent+    ( BlockTagContent (..)+    ) where++import ProAbstract.Annotation+import ProAbstract.Metadata+import ProAbstract.Structure.Block+import ProAbstract.Structure.CanBePlain+import ProAbstract.Structure.CanFork+import ProAbstract.Structure.Fork+import ProAbstract.Structure.HasManyParagraphs+import ProAbstract.Structure.HasManyPlainBlocks+import ProAbstract.Structure.HasManyPlainInlines+import ProAbstract.Structure.Plain+import ProAbstract.Structure.PlainBlock+import ProAbstract.Tag++data BlockTagContent ann =+    BlockTagContent_Fork  (Blocks ann)     -- ^ 'ProAbstract.fork'+  | BlockTagContent_Plain (PlainBlock ann) -- ^ 'ProAbstract.plain'++type instance Annotation (BlockTagContent ann) = ann++type instance Plain (BlockTagContent ann) = PlainBlock ann++type instance Fork (BlockTagContent ann) = Blocks ann++instance CanBePlain (BlockTagContent ann) where+    plain = prism' BlockTagContent_Plain \case+        BlockTagContent_Plain x -> Just x; _ -> Nothing++instance CanFork (BlockTagContent ann) where+    fork = prism' BlockTagContent_Fork \case+        BlockTagContent_Fork x -> Just x; _ -> Nothing++instance HasManyPlainBlocks (BlockTagContent ann) where+    allPlainBlocks = fork % allPlainBlocks++instance HasManyPlainInlines (BlockTagContent ann) where+    allPlainInlines = fork % allPlainInlines++instance HasManyAnnotations (BlockTagContent ann) (BlockTagContent ann') where+    allAnnotations = traversalVL \f -> \case+        BlockTagContent_Fork x -> BlockTagContent_Fork <$> traverseOf allAnnotations f x+        BlockTagContent_Plain x -> BlockTagContent_Plain <$> traverseOf allAnnotations f x++instance HasManyMetadata (BlockTagContent ann) where+    allMetadata = fork % allMetadata++instance HasManyTags (BlockTagContent ann) where+    allTags = fork % allTags+    allInlineTags = fork % allInlineTags++instance HasManyBlockTags (BlockTagContent ann) where+    allBlockTags = fork % allBlockTags++instance HasWitherableTags (BlockTagContent ann) where+    witherTags f = traverseOf fork (witherTags f)+    mapMaybeTags f = over fork (mapMaybeTags f)++instance HasWitherableInlineTags (BlockTagContent ann) where+    witherInlineTags f = traverseOf fork (witherInlineTags f)+    mapMaybeInlineTags f = over fork (mapMaybeInlineTags f)++instance HasWitherableBlockTags (BlockTagContent ann) where+    witherBlockTags f = traverseOf fork (witherBlockTags f)+    mapMaybeBlockTags f = over fork (mapMaybeBlockTags f)++instance HasManyParagraphs (BlockTagContent ann) where+    allParagraphs = fork % allParagraphs
library/pro-abstract/ProAbstract/Tagless/CanBeTagless.hs view
@@ -40,6 +40,9 @@             % all @Maybe (tagless s) -- If there is a block, it has to be convertable to the desired text kind             % to (fromMaybe (noText s)) -- If there are no blocks, return an empty line or stanza +instance CanBeTagless (BlockTagContent ann) where+    tagless s = (fork % tagless s) `afailing` (plain % tagless s)+ noText :: KindOfText txt -> txt noText = \case{ TextLine -> textEmpty; TextStanza -> Empty; TextParagraphs -> Empty } 
library/pro-abstract/ProAbstract/Tagless/CanHaveTaglessContent.hs view
@@ -21,6 +21,9 @@         (plain % taglessContent @(Tagged (PlainBlock ann)) s) `afailing`         (fork % taglessContent @(Tagged (Blocks ann)) s) +instance CanHaveTaglessContent (BlockTagContent ann) where+    taglessContent = tagless+ instance CanHaveTaglessContent (Inline ann) where     taglessContent s = (plain % tagless s) `afailing` (fork % taglessContent s) 
library/pro-abstract/ProAbstract/Types.hs view
@@ -3,6 +3,7 @@     , Block     , Blocks     , BlockTag+    , BlockTagContent     , Content     , Contents     , Document
pro-abstract.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: pro-abstract-version: 0.1.0.0+version: 0.1.1.0  category: Language synopsis: Abstract syntax for writing documents@@ -21,6 +21,8 @@     © 2020 James Alexander Feldman-Crough,     © 2022 Mission Valley Software LLC +extra-source-files: changelog.txt+ source-repository head     type: git     location: git://github.com/typeclasses/pro-abstract.git@@ -88,6 +90,7 @@       , ProAbstract.Metadata.MetadataType       , ProAbstract.Structure.Block       , ProAbstract.Structure.BlockTag+      , ProAbstract.Structure.BlockTagContent       , ProAbstract.Structure.CanBePlain       , ProAbstract.Structure.CanFork       , ProAbstract.Structure.Document