packages feed

pro-abstract 0.1.2.0 → 0.1.3.0

raw patch · 11 files changed

+153/−37 lines, 11 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ ProAbstract: IsBare :: BareType a -> TaggedOrBare a
+ ProAbstract: IsTagged :: TaggedType a -> TaggedOrBare a
+ ProAbstract: bare :: IsTaggedOrBare a => Prism' a (BareType a)
+ ProAbstract: class IsTaggedOrBare a where {
+ ProAbstract: data TaggedOrBare a
+ ProAbstract: tagged :: IsTaggedOrBare a => Prism' a (TaggedType a)
+ ProAbstract: taggedOrBare :: IsTaggedOrBare a => Iso' a (TaggedOrBare a)
+ ProAbstract.Classes: class IsTaggedOrBare a where {
+ ProAbstract.Classes: taggedOrBare :: IsTaggedOrBare a => Iso' a (TaggedOrBare a)
+ ProAbstract.Datatypes: IsBare :: BareType a -> TaggedOrBare a
+ ProAbstract.Datatypes: IsTagged :: TaggedType a -> TaggedOrBare a
+ ProAbstract.Datatypes: data TaggedOrBare a
+ ProAbstract.Optics: bare :: IsTaggedOrBare a => Prism' a (BareType a)
+ ProAbstract.Optics: tagged :: IsTaggedOrBare a => Prism' a (TaggedType a)
+ ProAbstract.Optics: taggedOrBare :: IsTaggedOrBare a => Iso' a (TaggedOrBare a)
+ ProAbstract.Structure: IsBare :: BareType a -> TaggedOrBare a
+ ProAbstract.Structure: IsTagged :: TaggedType a -> TaggedOrBare a
+ ProAbstract.Structure: bare :: IsTaggedOrBare a => Prism' a (BareType a)
+ ProAbstract.Structure: class IsTaggedOrBare a where {
+ ProAbstract.Structure: data TaggedOrBare a
+ ProAbstract.Structure: tagged :: IsTaggedOrBare a => Prism' a (TaggedType a)
+ ProAbstract.Structure: taggedOrBare :: IsTaggedOrBare a => Iso' a (TaggedOrBare a)
+ ProAbstract.Structure: }
+ ProAbstract.Types: data TaggedOrBare a
- ProAbstract.Families: type family Plain a
+ ProAbstract.Families: type family BareType a
- ProAbstract.Structure: type family Fork a
+ ProAbstract.Structure: type family BareType a;

Files

changelog.txt view
@@ -4,3 +4,10 @@  v0.1.2.0 - Add instances (Eq, Show, Generic, Hashable, NFData)            to classes (BlockTag, BlockTagContent)++v0.1.3.0 - Add:+    - type TaggedOrBare+    - class IsTaggedOrBare+        - type families TaggedType and BareType+        - isomorphism 'taggedOrBare'+    - prisms 'tagged' and 'bare'
library/pro-abstract-prelude/Prelude.hs view
@@ -15,7 +15,7 @@  import Containers as X -import BasePrelude as X (Applicative, Bool, Either (..), Eq, Foldable, Functor, Maybe (..), Monad, Monoid (mempty), Ord, Semigroup (..), Show, Traversable, const, either, fmap, maybe, not, pure, traverse, ($), (.), (<$>), (<*>), (=<<), (>>=))+import BasePrelude as X (Applicative, Bool (..), Either (..), Eq, Foldable, Functor, Maybe (..), Monad, Monoid (mempty), Ord, Semigroup (..), Show, Traversable, const, either, fmap, maybe, not, pure, traverse, ($), (.), (<$>), (<*>), (=<<), (>>=)) -import Optics.Core as X (A_Fold, A_Getter, A_Lens, A_Traversal, AffineFold, AffineTraversal, AffineTraversal', An_AffineFold, An_AffineTraversal, An_Iso, Is, Iso, Iso', JoinKinds, Lens, Lens', NoIx, Optic, Optic', OpticKind, Prism', Traversal, Traversal', _Just, _Left, _Right, adjoin, afailing, afolding, atraversal, castOptic, coerced, equality, lens, matching, over, preview, prism', re, review, set, simple, to, traversalVL, traverseOf, traversed, view, (%), JoinKinds)+import Optics.Core as X (A_Fold, A_Getter, A_Lens, A_Traversal, AffineFold, AffineTraversal, AffineTraversal', An_AffineFold, An_AffineTraversal, An_Iso, Is, Iso, Iso', JoinKinds, Lens, Lens', NoIx, Optic, Optic', OpticKind, Prism', Traversal, Traversal', _Just, _Left, _Right, adjoin, afailing, afolding, atraversal, castOptic, coerced, equality, iso, lens, matching, over, preview, prism', re, review, set, simple, to, traversalVL, traverseOf, traversed, view, (%)) import Optics.Empty.Core as X (_Empty, pattern Empty)
library/pro-abstract/ProAbstract.hs view
@@ -44,7 +44,7 @@  /Block-level/ content is everything that appears below the document level and above the paragraph level. -- 'Block' = ('fork' : 'Tagged' 'Blocks') ∪ ('plain' : 'Tagged' 'PlainBlock') ∪ ('paragraph' : 'Paragraph')+- 'Block' = ('fork' : 'Tagged' 'Blocks') ∪ ('plain' : 'Tagged' 'PlainBlock') ∪ ('bare' : 'Paragraph')  There are three kinds of block: @@ -57,7 +57,7 @@     * 'Tagged' 'PlainBlock' = ('tag' : 'Tag') × ('content' : 'PlainBlock')     * 'PlainBlock' = ('contents' : 'Fragment') × ('annotation' : 'Annotation') -- /Paragraphs/ contain inline content.+- /Bare/ blocks (paragraphs) contain inline content.      * 'Paragraph' = ('contents' : 'Line') × ('annotation' : 'Annotation') @@ -72,9 +72,9 @@  The Block type can be described in terms of BlockTag as: -- 'Block' = ('blockTag' : 'BlockTag') ∪ ('paragraph' : 'Paragraph')+- 'Block' = ('tagged' : 'BlockTag') ∪ ('bare' : 'Paragraph') -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".+Example: @'tagged' % '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: @@ -88,17 +88,17 @@  Inline content is grouped into lines; we specify no particular semantics of line breaks but suggest that a typical consumer of 'Lines' will fold them together with a single space character interspersed between the lines. -- 'Inline' = ('fork' : 'Tagged' 'Lines') ∪ ('plain' : 'Fragment')+- 'Inline' = ('fork' or 'tagged' : 'Tagged' 'Lines') ∪ ('plain' or 'bare' : 'Fragment')  There are two kinds of inline: -- /Fork/ inlines contain more inlines.+- /Fork/ or /tag/ inlines contain more inlines.      * 'Tagged' 'Lines' = ('tag' : 'Tag') × ('content' : 'Lines')     * 'Lines' = ('contents' : 'Line')     * 'Line' = ('content' : 'Seq' 'Inline') × ('annotation' : 'Annotation') -- /Plain/ inlines contain text.+- /Plain/ or /bare/ inlines contain text.  Unenforced guideline: Each 'Line' should contain at least one 'Inline'. @@ -160,29 +160,40 @@ 'HasContent' and 'HasContents' have type aliases 'HasContents'' and 'HasContents'' respectively for types that only support simple optics.  -=== Fork and plain+=== Tagged or bare +At both the block and inline level, a node is either /tagged/ or /bare/, a fact manifested by the 'taggedOrBare' isomorphism of the 'IsTaggedOrBare' class.++The 'tagged' prism is overloaded via the 'TaggedType' type family, and the 'bare' prism is overloaded via the 'BareType' family.++List of nodes and their tagged/bare types:+++-----------------------+-----------------------+-----------------------++| __x__                 | __TaggedType x__      | __BareType x__        |++-----------------------+-----------------------+-----------------------++| 'Block'               | 'BlockTag'            | 'Paragraph'           |++-----------------------+-----------------------+-----------------------++| 'Inline'              | 'Tagged' 'Lines'      | 'Fragment'            |++-----------------------+-----------------------+-----------------------++++=== Fork or plain+ At both the block and inline level, a node may be a /fork/ that contains a sequence of more content at the same level, and a node may be /plain/ node that just contains text. -The 'fork' prism is overloaded via the 'Fork' type family and 'CanFork' class. List of nodes and their fork types:+The 'fork' prism is overloaded via the 'Fork' type family and 'CanFork' class. -+-----------------------+-----------------------+-| __x__                 | __Fork x__            |-+-----------------------+-----------------------+-| 'Block'               | 'Tagged' 'Blocks'     |-+-----------------------+-----------------------+-| 'Inline'              | 'Tagged' 'Lines'      |-+-----------------------+-----------------------++The 'plain' prism is overloaded via the 'Plain' type family and 'CanBePlain' class. -The 'plain' prism is overloaded via the 'Plain' type family and 'CanBePlain' class. List of nodes and their plain types:+List of nodes and their fork/plain types: -+-----------------------+-----------------------+-| __x__                 | __Plain x__           |-+-----------------------+-----------------------+-| 'Block'               | 'Tagged' 'PlainBlock' |-+-----------------------+-----------------------+-| 'Inline'              | 'Fragment'            |-+-----------------------+-----------------------+++-----------------------+-----------------------+-----------------------++| __x__                 | __Fork x__            | __Plain x__           |++-----------------------+-----------------------+-----------------------++| 'Block'               | 'Tagged' 'Blocks'     | 'Tagged' 'PlainBlock' |++-----------------------+-----------------------+-----------------------++| 'Inline'              | 'Tagged' 'Lines'      | 'Fragment'            |++-----------------------+-----------------------+-----------------------+  ('Block' also has a third prism, 'paragraph', which is neither fork nor plain.) @@ -239,6 +250,7 @@     {- * Prisms -}     {- ** Plain -} Plain, CanBePlain (..),     {- ** Fork -} Fork, CanFork (..),+    {- ** Tagged/bare -} tagged, bare, IsTaggedOrBare (..), TaggedOrBare (..),     {- ** Paragraph -} paragraph,      {- * Metadata -} Metadata (..), HasMetadata (..), HasManyMetadata (..),
library/pro-abstract/ProAbstract/Classes.hs view
@@ -1,7 +1,7 @@ module ProAbstract.Classes     (-    -- * Block and inline prisms-      CanBePlain (..), CanFork (..)+    -- * Block and inline choices+      CanBePlain (..), CanFork (..), IsTaggedOrBare (..)      -- * Plaintext traversals     , HasManyPlainBlocks (..), HasManyPlainInlines (..)
library/pro-abstract/ProAbstract/Datatypes.hs view
@@ -10,7 +10,7 @@     , Inline (..), Line (..), Lines (..)      -- * Tags and tagged things-    , Tag (..), Tagged (..), BlockTag (..)+    , Tag (..), Tagged (..), BlockTag (..), TaggedOrBare (..)      -- * Paragraph     , Paragraph (..)
library/pro-abstract/ProAbstract/Families.hs view
@@ -1,10 +1,20 @@ module ProAbstract.Families-    ( Annotation-    , Content-    , Contents-    , Fork-    , Plain+    (+    -- * Annotation+      Annotation++    -- * Content plus a tag     , Tagged++    -- ** Content+    , Content, Contents++    -- * Fork or plain+    , Fork, Plain++    -- * Tagged or bare+    , TaggedType, BareType+     ) where  import ProAbstract.Annotation
library/pro-abstract/ProAbstract/Optics.hs view
@@ -10,7 +10,10 @@     , metadata, atSetting, hasProperty, properties, settings      -- * Prisms-    , fork, plain, paragraph, blockTag+    , fork, plain, paragraph, blockTag, tagged, bare++    -- * Isomorphisms+    , taggedOrBare      -- * Traversals     , allParagraphs, allPlainBlocks, allPlainInlines
library/pro-abstract/ProAbstract/Structure.hs view
@@ -18,9 +18,12 @@     -- * Text     , PlainBlock (..), Fragment (..) -    -- * Plain and fork+    -- * Plain or fork     , CanBePlain (..), Plain, CanFork (..), Fork +    -- * Tagged or bare+    , IsTaggedOrBare (..), TaggedOrBare (..), tagged, bare+     -- * Traversals     , HasManyParagraphs (..), HasManyPlainBlocks (..), HasManyPlainInlines (..) @@ -39,6 +42,7 @@ import ProAbstract.Structure.HasManyPlainBlocks import ProAbstract.Structure.HasManyPlainInlines import ProAbstract.Structure.Inline+import ProAbstract.Structure.IsTaggedOrBare import ProAbstract.Structure.Paragraph import ProAbstract.Structure.Plain import ProAbstract.Structure.PlainBlock
+ library/pro-abstract/ProAbstract/Structure/IsTaggedOrBare.hs view
@@ -0,0 +1,78 @@+module ProAbstract.Structure.IsTaggedOrBare+    ( TaggedOrBare (..)+    , IsTaggedOrBare (..)+    , tagged, bare+    ) where++import ProAbstract.Structure.Block+import ProAbstract.Structure.BlockTag+import ProAbstract.Structure.Fragment+import ProAbstract.Structure.Inline+import ProAbstract.Structure.Paragraph++data TaggedOrBare a =+    IsTagged (TaggedType a)+  | IsBare (BareType a)++tagged' :: Prism' (TaggedOrBare a) (TaggedType a)+tagged' = prism' IsTagged \case{ IsTagged x -> Just x; _ -> Nothing }++bare' :: Prism' (TaggedOrBare a) (BareType a)+bare' = prism' IsBare \case{ IsBare x -> Just x; _ -> Nothing }++class IsTaggedOrBare a where++    type TaggedType a+    type BareType a++    taggedOrBare :: Iso' a (TaggedOrBare a)++tagged :: IsTaggedOrBare a => Prism' a (TaggedType a)+tagged = taggedOrBare % tagged'++bare :: IsTaggedOrBare a => Prism' a (BareType a)+bare = taggedOrBare % bare'++instance IsTaggedOrBare (TaggedOrBare a) where++    type TaggedType (TaggedOrBare a) = TaggedType a+    type BareType (TaggedOrBare a) = BareType a++    taggedOrBare = iso f g+      where+        f = \case+            IsTagged x -> IsTagged x+            IsBare x -> IsBare x+        g = \case+            IsTagged x -> IsTagged x+            IsBare x -> IsBare x++instance IsTaggedOrBare (Inline ann) where++    type TaggedType (Inline ann) = Tagged (Lines ann)+    type BareType (Inline ann) = Fragment ann++    taggedOrBare = iso f g+      where+        f = \case+            InlineFork x -> IsTagged x+            InlinePlain x -> IsBare x+        g = \case+            IsTagged x -> InlineFork x+            IsBare x -> InlinePlain x++instance IsTaggedOrBare (Block ann) where++    type TaggedType (Block ann) = BlockTag ann+    type BareType (Block ann) = Paragraph ann++    taggedOrBare = iso f g+      where+        f = \case+            BlockPlain x -> IsTagged (BlockTagPlain x)+            BlockFork x -> IsTagged (BlockTagFork x)+            BlockParagraph x -> IsBare x+        g = \case+            IsTagged (BlockTagPlain x) -> BlockPlain x+            IsTagged (BlockTagFork x) -> BlockFork x+            IsBare x -> BlockParagraph x
library/pro-abstract/ProAbstract/Types.hs view
@@ -21,6 +21,7 @@     , Set     , Tag     , Tagged+    , TaggedOrBare     , Text     ) where 
pro-abstract.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: pro-abstract-version: 0.1.2.0+version: 0.1.3.0  category: Language synopsis: Abstract syntax for writing documents@@ -100,6 +100,7 @@       , ProAbstract.Structure.HasManyPlainBlocks       , ProAbstract.Structure.HasManyPlainInlines       , ProAbstract.Structure.Inline+      , ProAbstract.Structure.IsTaggedOrBare       , ProAbstract.Structure.Paragraph       , ProAbstract.Structure.Plain       , ProAbstract.Structure.PlainBlock