Copyright | ©2020 James Alexander Feldman-Crough |
---|---|
License | MPL-2.0 |
Maintainer | alex@fldcr.com |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Offset
- data Column
- data Line
- data Location
- data Source
- newtype Assoc k v = Assoc (HashMap k v)
- data InvalidCharacter
- data KeyError
- data Key
- makeKey :: Text -> Either KeyError Key
- rawKey :: Key -> Text
- data SeriesNE a
- newtype Series a = Series (Seq a)
- newtype Set a = Set (HashSet a)
- type LiteralTag = Tag Text
- type InlineTag = Tag (Series Inline)
- type BlockTag = Tag (Series Block)
- data Tag a = Tag {
- tagName :: Key
- tagMetadata :: Metadata
- tagContent :: a
- tagLocation :: Maybe Location
- data Region a = Region {}
- data Paragraph = Paragraph {}
- data Metadata = Metadata {}
- data Inline
- data Fragment = Fragment {}
- data Document = Document {}
- data Block
- documentToRegion :: Document -> Region (Series Block)
- regionToDocument :: Region (Series Block) -> Document
- tagToRegion :: Tag a -> Region a
- regionToTag :: Key -> Region a -> Tag a
- newtype Failure = Failure (ParseErrorBundle Text Void)
- parseDocument :: FilePath -> Text -> Either Failure Document
- readDocument :: FilePath -> IO Document
- parseDocumentMetadata :: FilePath -> Text -> Either Failure Metadata
- readDocumentMetadata :: FilePath -> IO Metadata
- prettyFailure :: Failure -> String
- class HasLocation t where
- offset :: HasLocation l => Affine' l Offset
- column :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Column
- line :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Line
- source :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Source
- sparse :: Iso' Location SparseLocation
- class HasContent t where
- class HasMetadata t where
- properties :: HasMetadata m => Lens' m (Set Key)
- settings :: HasMetadata m => Lens' m (Assoc Key Text)
- hasProperty :: HasMetadata m => Key -> Lens' m Bool
- atSetting :: HasMetadata m => Key -> Lens' m (Maybe Text)
- tag :: Lens' (Tag a) Key
- fragment :: Lens' Fragment Text
- tagged :: Key -> Prism' (Tag a) (Region a)
- _BlockTag :: Prism' Block BlockTag
- _BlockParagraph :: Prism' Block Paragraph
- _BlockLiteral :: Prism' Block LiteralTag
- _InlineTag :: Prism' Inline InlineTag
- _Text :: Prism' Inline Fragment
- _Break :: Prism' Inline ()
- key :: Prism' Text Key
- _Assoc :: Iso (Assoc k v) (Assoc k' v') (HashMap k v) (HashMap k' v')
- _NonEmpty :: Prism' (Series a) (SeriesNE a)
- _Series :: Iso (Series a) (Series b) (Seq a) (Seq b)
- _SeriesNE :: Prism' (Seq a) (SeriesNE a)
- _Set :: Iso (Set a) (Set b) (HashSet a) (HashSet b)
Documentation
An offset into a Source
, counted by UTF-8 codepoint.
Instances
A column number.
Instances
Enum Column Source # | |
Defined in Prosidy.Source | |
Eq Column Source # | |
Ord Column Source # | |
Show Column Source # | |
Generic Column Source # | |
Hashable Column Source # | |
Defined in Prosidy.Source | |
ToJSON Column Source # | |
Defined in Prosidy.Source | |
FromJSON Column Source # | |
Binary Column Source # | |
NFData Column Source # | |
Defined in Prosidy.Source | |
type Rep Column Source # | |
Defined in Prosidy.Source |
A line number.
The Show
instance for Line
counts from one, while the internal
implementation counts from zero.
Instances
Enum Line Source # | |
Eq Line Source # | |
Ord Line Source # | |
Show Line Source # | |
Generic Line Source # | |
Hashable Line Source # | |
Defined in Prosidy.Source | |
ToJSON Line Source # | |
Defined in Prosidy.Source | |
FromJSON Line Source # | |
Binary Line Source # | |
NFData Line Source # | |
Defined in Prosidy.Source | |
type Rep Line Source # | |
Defined in Prosidy.Source |
A location in a Source
, with the line and column number computed lazily.
Instances
Eq Location Source # | |
Show Location Source # | |
Generic Location Source # | |
Hashable Location Source # | |
Defined in Prosidy.Source | |
Binary Location Source # | |
NFData Location Source # | |
Defined in Prosidy.Source | |
HasLocation Location Source # | |
type Rep Location Source # | |
Defined in Prosidy.Source type Rep Location = D1 ('MetaData "Location" "Prosidy.Source" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) ((S1 ('MetaSel ('Just "locationSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Source) :*: S1 ('MetaSel ('Just "locationOffset") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Offset)) :*: (S1 ('MetaSel ('Just "locationLine") 'NoSourceUnpackedness 'SourceLazy 'DecidedLazy) (Rec0 Line) :*: S1 ('MetaSel ('Just "locationColumn") 'NoSourceUnpackedness 'SourceLazy 'DecidedLazy) (Rec0 Column)))) |
Information about Prosidy source file.
The Show
instance for ths class does not include the LineMap
or Text
fields, as those are rather noisy.
Instances
Eq Source Source # | |
Show Source Source # | |
Generic Source Source # | |
Hashable Source Source # | |
Defined in Prosidy.Source | |
Binary Source Source # | |
NFData Source Source # | |
Defined in Prosidy.Source | |
type Rep Source Source # | |
Defined in Prosidy.Source type Rep Source = D1 ('MetaData "Source" "Prosidy.Source" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Source" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String) :*: (S1 ('MetaSel ('Just "sourceText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "sourceLineMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LineMap)))) |
An associative mapping of keys to values.
Currently implemented as a HashMap
, this newtype wrapper allows us to:
1) Add non-orphan instances to the underlying structure. 2) Change the underlying type if needed.
Instances
Functor (Assoc k) Source # | |
Foldable (Assoc k) Source # | |
Defined in Prosidy.Types.Assoc fold :: Monoid m => Assoc k m -> m # foldMap :: Monoid m => (a -> m) -> Assoc k a -> m # foldMap' :: Monoid m => (a -> m) -> Assoc k a -> m # foldr :: (a -> b -> b) -> b -> Assoc k a -> b # foldr' :: (a -> b -> b) -> b -> Assoc k a -> b # foldl :: (b -> a -> b) -> b -> Assoc k a -> b # foldl' :: (b -> a -> b) -> b -> Assoc k a -> b # foldr1 :: (a -> a -> a) -> Assoc k a -> a # foldl1 :: (a -> a -> a) -> Assoc k a -> a # elem :: Eq a => a -> Assoc k a -> Bool # maximum :: Ord a => Assoc k a -> a # minimum :: Ord a => Assoc k a -> a # | |
(Eq k, Eq v) => Eq (Assoc k v) Source # | |
(Show k, Show v) => Show (Assoc k v) Source # | |
Generic (Assoc k v) Source # | |
(Eq k, Hashable k) => Semigroup (Assoc k v) Source # | |
(Eq k, Hashable k) => Monoid (Assoc k v) Source # | |
(Hashable k, Hashable v) => Hashable (Assoc k v) Source # | |
Defined in Prosidy.Types.Assoc | |
(ToJSON v, ToJSONKey k) => ToJSON (Assoc k v) Source # | |
Defined in Prosidy.Types.Assoc | |
(FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON (Assoc k v) Source # | |
(Eq k, Hashable k, Binary k, Binary v) => Binary (Assoc k v) Source # | |
(NFData k, NFData v) => NFData (Assoc k v) Source # | |
Defined in Prosidy.Types.Assoc | |
type Rep (Assoc k v) Source # | |
Defined in Prosidy.Types.Assoc |
data InvalidCharacter Source #
Details for errors thrown when creating Key
s with one or more invalid
characters.
Instances
Eq InvalidCharacter Source # | |
Defined in Prosidy.Types.Key (==) :: InvalidCharacter -> InvalidCharacter -> Bool # (/=) :: InvalidCharacter -> InvalidCharacter -> Bool # | |
Show InvalidCharacter Source # | |
Defined in Prosidy.Types.Key showsPrec :: Int -> InvalidCharacter -> ShowS # show :: InvalidCharacter -> String # showList :: [InvalidCharacter] -> ShowS # |
Errors returned when creating invalid keys.
InvalidCharacterError InvalidCharacter | A character provided as a |
EmptyKeyError | A string of length 0 was provided as a |
Instances
Eq KeyError Source # | |
Show KeyError Source # | |
Exception KeyError Source # | |
Defined in Prosidy.Types.Key toException :: KeyError -> SomeException # fromException :: SomeException -> Maybe KeyError # displayException :: KeyError -> String # |
A Key
is an identifier used in tags, properties, and setting names.
Instances
Eq Key Source # | |
Ord Key Source # | |
Show Key Source # | |
IsString Key Source # |
|
Defined in Prosidy.Types.Key fromString :: String -> Key # | |
Generic Key Source # | |
Hashable Key Source # | |
Defined in Prosidy.Types.Key | |
ToJSON Key Source # | |
Defined in Prosidy.Types.Key | |
ToJSONKey Key Source # | |
Defined in Prosidy.Types.Key | |
FromJSON Key Source # | |
FromJSONKey Key Source # | |
Defined in Prosidy.Types.Key | |
Binary Key Source # | |
NFData Key Source # | |
Defined in Prosidy.Types.Key | |
type Rep Key Source # | |
Defined in Prosidy.Types.Key |
A non-empty Series
.
Instances
A newtype wrapper around a sequential collection.
Currently, Series
is implemented as a Seq
, but this is not guarenteed to
be true.
Instances
A newtype wrapper around an unordered collection of unique elements.
Currently, this is implemented as a wrapper around a HashSet
.
Instances
Foldable Set Source # | |
Defined in Prosidy.Types.Set fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Eq a => Eq (Set a) Source # | |
Show a => Show (Set a) Source # | |
Generic (Set a) Source # | |
(Hashable a, Eq a) => Semigroup (Set a) Source # | |
(Hashable a, Eq a) => Monoid (Set a) Source # | |
Hashable a => Hashable (Set a) Source # | |
Defined in Prosidy.Types.Set | |
(Hashable a, Eq a, ToJSONKey a) => ToJSON (Set a) Source # | |
Defined in Prosidy.Types.Set | |
(Hashable a, Eq a, FromJSONKey a) => FromJSON (Set a) Source # | |
(Eq a, Hashable a, Binary a) => Binary (Set a) Source # | |
NFData a => NFData (Set a) Source # | |
Defined in Prosidy.Types.Set | |
type Rep (Set a) Source # | |
Defined in Prosidy.Types.Set |
type LiteralTag = Tag Text Source #
A Tag
containing a single plain-text item.
Specified in Prosidy source with the #=
sigil.
A Region
, annotated with a tag name.
Tag | |
|
Instances
An untagged structural grouping of items with type a
. Regions do not
occur in parsing.
Region | |
|
Instances
A non-empty collection of Inline
items. A Paragraph
represents the
border between block and inline contexts. All ancestors of a paragraph are
block items or a document, and all children are inline items.
Instances
Eq Paragraph Source # | |
Show Paragraph Source # | |
Generic Paragraph Source # | |
Hashable Paragraph Source # | |
Defined in Prosidy.Types | |
ToJSON Paragraph Source # | |
Defined in Prosidy.Types | |
FromJSON Paragraph Source # | |
Binary Paragraph Source # | |
NFData Paragraph Source # | |
Defined in Prosidy.Types | |
HasLocation Paragraph Source # | |
HasContent Paragraph Source # | |
type Rep Paragraph Source # | |
Defined in Prosidy.Types type Rep Paragraph = D1 ('MetaData "Paragraph" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Paragraph" 'PrefixI 'True) (S1 ('MetaSel ('Just "paragraphContent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (SeriesNE Inline)) :*: S1 ('MetaSel ('Just "paragraphLocation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Location)))) | |
type Content Paragraph Source # | |
Defined in Prosidy.Optics.Types |
A set of properties and settings, associated with a Region
.
The namespaces of properties and settings are distinct; a property can share a name with a setting without conflict.
Metadata | |
|
Instances
Eq Metadata Source # | |
Show Metadata Source # | |
Generic Metadata Source # | |
Semigroup Metadata Source # | |
Monoid Metadata Source # | |
Hashable Metadata Source # | |
Defined in Prosidy.Types | |
ToJSON Metadata Source # | |
Defined in Prosidy.Types | |
FromJSON Metadata Source # | |
Binary Metadata Source # | |
NFData Metadata Source # | |
Defined in Prosidy.Types | |
HasMetadata Metadata Source # | |
type Rep Metadata Source # | |
Defined in Prosidy.Types type Rep Metadata = D1 ('MetaData "Metadata" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Metadata" 'PrefixI 'True) (S1 ('MetaSel ('Just "metadataProperties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Set Key)) :*: S1 ('MetaSel ('Just "metadataSettings") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Assoc Key Text)))) |
A sum type enumerating allowed types inside of an inline context.
Break | Spacing recorded between lines or on either side of an |
InlineTag InlineTag | A |
InlineText Fragment | A fragment of plain text. |
Instances
Eq Inline Source # | |
Show Inline Source # | |
Generic Inline Source # | |
Hashable Inline Source # | |
Defined in Prosidy.Types | |
ToJSON Inline Source # | |
Defined in Prosidy.Types | |
FromJSON Inline Source # | |
Binary Inline Source # | |
NFData Inline Source # | |
Defined in Prosidy.Types | |
HasLocation Inline Source # | |
type Rep Inline Source # | |
Defined in Prosidy.Types type Rep Inline = D1 ('MetaData "Inline" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Break" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InlineTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 InlineTag)) :+: C1 ('MetaCons "InlineText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Fragment)))) |
Plain text, possibly annotated with a Location
.
Fragment | |
|
Instances
Eq Fragment Source # | |
Show Fragment Source # | |
Generic Fragment Source # | |
Hashable Fragment Source # | |
Defined in Prosidy.Types | |
ToJSON Fragment Source # | |
Defined in Prosidy.Types | |
FromJSON Fragment Source # | |
Binary Fragment Source # | |
NFData Fragment Source # | |
Defined in Prosidy.Types | |
HasLocation Fragment Source # | |
type Rep Fragment Source # | |
Defined in Prosidy.Types type Rep Fragment = D1 ('MetaData "Fragment" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Fragment" 'PrefixI 'True) (S1 ('MetaSel ('Just "fragmentText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "fragmentLocation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Location)))) |
A full Prosidy document.
Instances
Eq Document Source # | |
Show Document Source # | |
Generic Document Source # | |
Hashable Document Source # | |
Defined in Prosidy.Types | |
ToJSON Document Source # | |
Defined in Prosidy.Types | |
FromJSON Document Source # | |
Binary Document Source # | |
NFData Document Source # | |
Defined in Prosidy.Types | |
HasContent Document Source # | |
HasMetadata Document Source # | |
type Rep Document Source # | |
Defined in Prosidy.Types type Rep Document = D1 ('MetaData "Document" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "Document" 'PrefixI 'True) (S1 ('MetaSel ('Just "documentMetadata") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Metadata) :*: S1 ('MetaSel ('Just "documentContent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Series Block)))) | |
type Content Document Source # | |
Defined in Prosidy.Optics.Types |
A sum type enumerating allowed types inside of a block context.
Instances
Eq Block Source # | |
Show Block Source # | |
Generic Block Source # | |
Hashable Block Source # | |
Defined in Prosidy.Types | |
ToJSON Block Source # | |
Defined in Prosidy.Types | |
FromJSON Block Source # | |
Binary Block Source # | |
NFData Block Source # | |
Defined in Prosidy.Types | |
HasLocation Block Source # | |
type Rep Block Source # | |
Defined in Prosidy.Types type Rep Block = D1 ('MetaData "Block" "Prosidy.Types" "prosidy-1.6.0.0-inplace" 'False) (C1 ('MetaCons "BlockLiteral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LiteralTag)) :+: (C1 ('MetaCons "BlockParagraph" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Paragraph)) :+: C1 ('MetaCons "BlockTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BlockTag)))) |
A parsing error.
Instances
Show Failure Source # | |
Exception Failure Source # | |
Defined in Prosidy.Parse toException :: Failure -> SomeException # fromException :: SomeException -> Maybe Failure # displayException :: Failure -> String # |
readDocument :: FilePath -> IO Document Source #
Reads a Prosidy Document
from the given FilePath
.
Errors will be thrown as exceptions. Use parseDocument
for a pure
implementation.
readDocumentMetadata :: FilePath -> IO Metadata Source #
Reads a Prosidy document's Metadata
header from the given FilePath
.
Errors will be thrown as exceptions. Use parseDocumentMetadata
for a pure
implementation.
prettyFailure :: Failure -> String Source #
Pretty-print a Failure
into a message acceptable for displaying to
users.
class HasLocation t where Source #
A classy optic for selecting the Location
from a value. Note that
location
is affine: a Location
can't be attached to a value which does
not -- already have one, and not all values with an instance of
HasLocation
have a location.
Instances
offset :: HasLocation l => Affine' l Offset Source #
column :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Column Source #
line :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Line Source #
source :: (HasLocation l, Contravariant f, Applicative f) => Optic' (->) f l Source Source #
sparse :: Iso' Location SparseLocation Source #
An isomorphism between Location
and SparseLocation
. This is allowed
because although a Location
has strictly more data than a SparseLocation
,
those values are denormalizations of values within SparseLocation
.
class HasContent t where Source #
An optic for selecting children of an item in a recursive structure.
Instances
class HasMetadata t where Source #
Instances
properties :: HasMetadata m => Lens' m (Set Key) Source #
Fetch all properties from items which contain metadata.
settings :: HasMetadata m => Lens' m (Assoc Key Text) Source #
Fetch all settings defined on items which contain metadata.
hasProperty :: HasMetadata m => Key -> Lens' m Bool Source #
atSetting :: HasMetadata m => Key -> Lens' m (Maybe Text) Source #
Select a setting from an item attached to metadata. Returns Nothing
if
no value is set.
_BlockParagraph :: Prism' Block Paragraph Source #
Focus only on paragraphs'
_BlockLiteral :: Prism' Block LiteralTag Source #
Focus only on literal tags.
_InlineTag :: Prism' Inline InlineTag Source #
Focus only on inline tags.
_NonEmpty :: Prism' (Series a) (SeriesNE a) Source #
A prism between possibly-empty and non-empty containers.