prosidy 1.5.0.1 → 1.6.0.0
raw patch · 8 files changed
+73/−9 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Prosidy.Types.Series: instance GHC.Base.Monoid (Prosidy.Types.Series.SeriesNE a)
+ Prosidy: Fragment :: Text -> Maybe Location -> Fragment
+ Prosidy: [fragmentLocation] :: Fragment -> Maybe Location
+ Prosidy: [fragmentText] :: Fragment -> Text
+ Prosidy: data Fragment
+ Prosidy: fragment :: Lens' Fragment Text
+ Prosidy.Optics.Source: instance Prosidy.Optics.Source.HasLocation Prosidy.Types.Block
+ Prosidy.Optics.Source: instance Prosidy.Optics.Source.HasLocation Prosidy.Types.Fragment
+ Prosidy.Optics.Source: instance Prosidy.Optics.Source.HasLocation Prosidy.Types.Inline
+ Prosidy.Optics.Types: fragment :: Lens' Fragment Text
+ Prosidy.Types: Fragment :: Text -> Maybe Location -> Fragment
+ Prosidy.Types: [fragmentLocation] :: Fragment -> Maybe Location
+ Prosidy.Types: [fragmentText] :: Fragment -> Text
+ Prosidy.Types: data Fragment
+ Prosidy.Types: instance Control.DeepSeq.NFData Prosidy.Types.Fragment
+ Prosidy.Types: instance Data.Aeson.Types.FromJSON.FromJSON Prosidy.Types.Fragment
+ Prosidy.Types: instance Data.Aeson.Types.ToJSON.ToJSON Prosidy.Types.Fragment
+ Prosidy.Types: instance Data.Binary.Class.Binary Prosidy.Types.Fragment
+ Prosidy.Types: instance Data.Hashable.Class.Hashable Prosidy.Types.Fragment
+ Prosidy.Types: instance GHC.Classes.Eq Prosidy.Types.Fragment
+ Prosidy.Types: instance GHC.Generics.Generic Prosidy.Types.Fragment
+ Prosidy.Types: instance GHC.Show.Show Prosidy.Types.Fragment
- Prosidy: InlineText :: Text -> Inline
+ Prosidy: InlineText :: Fragment -> Inline
- Prosidy: _Text :: Prism' Inline Text
+ Prosidy: _Text :: Prism' Inline Fragment
- Prosidy.Optics.Types: _Text :: Prism' Inline Text
+ Prosidy.Optics.Types: _Text :: Prism' Inline Fragment
- Prosidy.Types: InlineText :: Text -> Inline
+ Prosidy.Types: InlineText :: Fragment -> Inline
Files
- CHANGELOG +5/−0
- README.pro +7/−3
- prosidy.cabal +1/−1
- src/Prosidy/Optics/Source.hs +28/−0
- src/Prosidy/Optics/Types.hs +7/−1
- src/Prosidy/Parse.hs +2/−2
- src/Prosidy/Types.hs +22/−1
- src/Prosidy/Types/Series.hs +1/−1
CHANGELOG view
@@ -1,3 +1,8 @@+# v1.6 _(2020-03-01)_+- Removed an erroneous `Monoid` constraint from `SeriesNE`+- Added locations to a few node types.+- Wrapped 'Text' nodes in 'Fragment'.+ # v1.5.0.1 _(2020-02-24)_ - Added `CHANGELOG` to its own file. - Included `CHANGELOG` and `README.pro` in the source distribution.
README.pro view
@@ -1,12 +1,16 @@ title: Prosidy README --- +#link[uri='https://ci.fldcr.com/prosidy/prosidy']{+#image[uri='https://ci.fldcr.com/api/badges/prosidy/prosidy/status.svg', desc='Build Status']+}+ Prosidy is a small language for writing documents. -Like #link[url='https://daringfireball.net/projects/markdown/']{Markdown},+Like #link[uri='https://daringfireball.net/projects/markdown/']{Markdown}, Prosidy's syntax is lightweight; it doesn't get in the way of your text. -Like #link[url='https://www.w3.org/XML/']{XML},+Like #link[uri='https://www.w3.org/XML/']{XML}, Prosidy is extensible: it doesn't make any assumptions about your content. You'll never have to fight to make your data fit a structure that wasn't designed for it. @@ -25,7 +29,7 @@ be careful before using it for anything critical! That said, feedback is more than welcome!-Reach me at #link[url='mailto:alex@fldcr.com']{alex@fldcr.com}.+Reach me at #link[uri='mailto:alex@fldcr.com']{alex@fldcr.com}. #-h{Developing Prosidy} This project sets up an environment using direnv and Nix.
prosidy.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: prosidy-version: 1.5.0.1+version: 1.6.0.0 synopsis: A simple language for writing documents. license: MPL-2.0 license-file: LICENSE
src/Prosidy/Optics/Source.hs view
@@ -42,9 +42,37 @@ location = affine' regionLocation (\d l -> d { regionLocation = Just l }) {-# INLINE location #-} +instance HasLocation Fragment where+ location =+ affine' fragmentLocation (\d l -> d { fragmentLocation = Just l })+ {-# INLINE location #-}+ instance HasLocation Paragraph where location = affine' paragraphLocation (\d l -> d { paragraphLocation = Just l })+ {-# INLINE location #-}++instance HasLocation Block where+ location = affine' get set+ where+ get (BlockLiteral lit) = tagLocation lit+ get (BlockParagraph p ) = paragraphLocation p+ get (BlockTag tag) = tagLocation tag+ set (BlockLiteral lit) l = BlockLiteral lit { tagLocation = Just l }+ set (BlockParagraph p) l =+ BlockParagraph p { paragraphLocation = Just l }+ set (BlockTag tag) l = BlockTag tag { tagLocation = Just l }+ {-# INLINE location #-}++instance HasLocation Inline where+ location = affine' get set+ where+ get Break = Nothing+ get (InlineTag tag) = tagLocation tag+ get (InlineText f ) = fragmentLocation f+ set Break _ = Break+ set (InlineTag tag) l = InlineTag tag { tagLocation = Just l }+ set (InlineText f ) l = InlineText f { fragmentLocation = Just l } {-# INLINE location #-} -- | Focus on the 'Offset' from a value parsed from a source file. If the
src/Prosidy/Optics/Types.hs view
@@ -20,6 +20,7 @@ , HasContent(..) -- * Accessors for fields not otherwise covered , tag+ , fragment -- * Conversion between 'Tag's and 'Region's. , tagged -- * Prisms on 'Block' contexts@@ -157,6 +158,11 @@ {-# INLINE tag #-} -------------------------------------------------------------------------------+-- | Get the contents of a 'Fragment'.+fragment :: Lens' Fragment Text+fragment = lens fragmentText (\f t -> f { fragmentText = t })++------------------------------------------------------------------------------- -- | Focus on the inner 'Region' of 'Tag's with a name. This can be used to -- filter 'Tag's to a specific subset for manipulation. tagged :: Key -> Prism' (Tag a) (Region a)@@ -190,7 +196,7 @@ _ -> Nothing -- | Focus only on text nodes.-_Text :: Prism' Inline Text+_Text :: Prism' Inline Fragment _Text = prism' InlineText $ \case InlineText t -> Just t _ -> Nothing
src/Prosidy/Parse.hs view
@@ -360,8 +360,8 @@ skipSpaces pure . Text.Lazy.toStrict . fold $ parts -fragment :: P Text-fragment = text+fragment :: P Fragment+fragment = annotateSource $ Fragment <$> text text :: P Text text = do
src/Prosidy/Types.hs view
@@ -38,6 +38,8 @@ -- * Common structures , Metadata(..) , Region(..)+ -- * Textual fragments+ , Fragment(..) -- * Utility wrappers , module X )@@ -68,6 +70,7 @@ import Data.Aeson ( ToJSON(..) , FromJSON(..) , withObject+ , withText , (.:) , (.=) , object@@ -155,6 +158,24 @@ regionToDocument (Region md ct _) = Document md ct -------------------------------------------------------------------------------+-- | Plain text, possibly annotated with a 'Location'.+data Fragment = Fragment+ { fragmentText :: Text+ -- ^ Access the underlying 'Text'.+ , fragmentLocation :: Maybe Location+ -- ^ The location of the 'Text' in the source code.+ }+ deriving stock (Eq, Show, Generic)+ deriving anyclass (Hashable, Binary, NFData)++instance FromJSON Fragment where+ parseJSON = withText "Fragment" $ pure . flip Fragment Nothing++instance ToJSON Fragment where+ toEncoding = toEncoding . fragmentText+ toJSON = toJSON . fragmentText++------------------------------------------------------------------------------- -- | A sum type enumerating allowed types inside of an inline context. data Inline = Break@@ -166,7 +187,7 @@ | InlineTag InlineTag -- ^ A 'Tag' which contains only 'Inline' items. These tags begin with the -- @#@ sigil in source.- | InlineText Text+ | InlineText Fragment -- ^ A fragment of plain text. deriving stock (Eq, Show, Generic) deriving anyclass (Hashable, Binary, NFData)
src/Prosidy/Types/Series.hs view
@@ -60,7 +60,7 @@ -- | A non-empty 'Series'. newtype SeriesNE a = SeriesNE (Seq a) deriving stock (Generic, Show)- deriving newtype (Eq, Foldable, Functor, Applicative, ToJSON, NFData, Semigroup, Monoid)+ deriving newtype (Eq, Foldable, Functor, Applicative, ToJSON, NFData, Semigroup) instance Binary a => Binary (SeriesNE a) where get =