| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Yamlet.Internal.Syntax
Description
The types of the syntax tree.
This module is intended for internal use only, and may change without warning in subsequent releases.
Synopsis
- data Document = Document {
- version :: !(Maybe YamlVersion)
- explicitStart :: !Bool
- explicitEnd :: !Bool
- docComments :: !Comments
- root :: !Node
- data YamlVersion = YamlVersion {}
- document :: Node -> Document
- data Node = Node {}
- data Content where
- ScalarLinesContent !ScalarStyle !Text ![Int]
- SequenceContent !CollectionStyle ![Node]
- MappingContent !CollectionStyle ![(Node, Node)]
- AliasContent !Text
- pattern ScalarContent :: ScalarStyle -> Text -> Content
- data Props = Props {}
- noProps :: Props
- data Tag
- = NoTag
- | NonSpecificTag
- | Tag !Text
- data ScalarStyle
- isBlockScalar :: ScalarStyle -> Bool
- data CollectionStyle
- contentNode :: Content -> Node
- scalarNode :: ScalarStyle -> Text -> Node
- plainNode :: Text -> Node
- sequenceNode :: [Node] -> Node
- mappingNode :: [(Node, Node)] -> Node
- data Comments = Comments {}
- noComments :: Comments
- withComments :: Comments -> Node -> Node
- data Commented a = Commented {}
- data Line where
- EmptyLine
- CommentLine !Int !Text
- pattern Comment :: Text -> Line
- newtype Offset = Offset Int
- noOffset :: Offset
- data Located a = Located {}
- copyDocument :: Document -> Document
- copyNode :: Node -> Node
- copyComments :: Comments -> Comments
Documents
A document of a YAML stream.
Constructors
| Document | |
Fields
| |
Instances
| NFData Document Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Document Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Document Source # | |||||
| Eq Document Source # | |||||
| type Rep Document Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Document = D1 ('MetaData "Document" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Document" 'PrefixI 'True) ((S1 ('MetaSel ('Just "version") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe YamlVersion)) :*: S1 ('MetaSel ('Just "explicitStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "explicitEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "docComments") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Comments) :*: S1 ('MetaSel ('Just "root") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Node))))) | |||||
data YamlVersion Source #
The version of YAML that a document declares.
Constructors
| YamlVersion | |
Instances
| NFData YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax Methods rnf :: YamlVersion -> () | |||||
| Generic YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax Methods showsPrec :: Int -> YamlVersion -> ShowS show :: YamlVersion -> String showList :: [YamlVersion] -> ShowS | |||||
| Eq YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Ord YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax Methods compare :: YamlVersion -> YamlVersion -> Ordering (<) :: YamlVersion -> YamlVersion -> Bool (<=) :: YamlVersion -> YamlVersion -> Bool (>) :: YamlVersion -> YamlVersion -> Bool (>=) :: YamlVersion -> YamlVersion -> Bool max :: YamlVersion -> YamlVersion -> YamlVersion min :: YamlVersion -> YamlVersion -> YamlVersion | |||||
| type Rep YamlVersion Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep YamlVersion = D1 ('MetaData "YamlVersion" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "YamlVersion" 'PrefixI 'True) (S1 ('MetaSel ('Just "major") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "minor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))) | |||||
document :: Node -> Document Source #
A document with the given root, without directives, markers and comments.
Nodes
A node of a document.
Constructors
| Node | |
Instances
| NFData Node Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Node Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Node Source # | |||||
| Eq Node Source # | |||||
| FromYaml Node Source # | The node of the syntax tree, with its styles and comments, e.g. to write a part of a document back as it was written. An alias in the input gives a copy of the node that it refers to. The texts of the node are copies, so that a small part of a document does
not keep the whole input alive. For a whole document without a copy, use
| ||||
| ToYaml Node Source # | |||||
| type Rep Node Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Node = D1 ('MetaData "Node" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Node" 'PrefixI 'True) ((S1 ('MetaSel ('Just "offset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Offset) :*: S1 ('MetaSel ('Just "endOffset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Offset)) :*: (S1 ('MetaSel ('Just "props") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Props) :*: (S1 ('MetaSel ('Just "comments") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Comments) :*: S1 ('MetaSel ('Just "content") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Content))))) | |||||
The content of a node.
Constructors
| ScalarLinesContent !ScalarStyle !Text ![Int] | A scalar with the positions in its text where the source continues on a new line. A position counts the characters from the start of the text, and the positions are in ascending order. The parser gives them for the plain, quoted and folded styles, which join the lines of the source, so that the renderer can write the text on the same lines. The renderer ignores a position where the style of the output cannot start a new line and keep the text. |
| SequenceContent !CollectionStyle ![Node] | |
| MappingContent !CollectionStyle ![(Node, Node)] | |
| AliasContent !Text | An alias, with the name of its anchor. An alias has no properties. |
Bundled Patterns
| pattern ScalarContent :: ScalarStyle -> Text -> Content | A scalar without positions of new lines. As a pattern, it matches every scalar and ignores its positions. |
Instances
| NFData Content Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Content Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Content Source # | |||||
| Eq Content Source # | |||||
| type Rep Content Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Content = D1 ('MetaData "Content" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) ((C1 ('MetaCons "ScalarLinesContent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ScalarStyle) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Int]))) :+: C1 ('MetaCons "SequenceContent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CollectionStyle) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Node]))) :+: (C1 ('MetaCons "MappingContent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CollectionStyle) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [(Node, Node)])) :+: C1 ('MetaCons "AliasContent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) | |||||
The properties of a node.
Instances
| NFData Props Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Props Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Props Source # | |||||
| Eq Props Source # | |||||
| type Rep Props Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Props = D1 ('MetaData "Props" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Props" 'PrefixI 'True) (S1 ('MetaSel ('Just "anchor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "tag") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag))) | |||||
The tag of a node after the tag handles are expanded.
Constructors
| NoTag | The node has no tag. |
| NonSpecificTag | The |
| Tag !Text | A specific tag, e.g. |
Instances
| NFData Tag Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Tag Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Tag Source # | |||||
| Eq Tag Source # | |||||
| Ord Tag Source # | |||||
| type Rep Tag Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Tag = D1 ('MetaData "Tag" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "NoTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NonSpecificTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) | |||||
data ScalarStyle Source #
The style of a scalar: without quotes, in single or double quotes, or a
literal (|) or folded (>) block scalar.
Constructors
| Plain | |
| SingleQuoted | |
| DoubleQuoted | |
| Literal | |
| Folded |
Instances
| NFData ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax Methods rnf :: ScalarStyle -> () | |||||
| Bounded ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Enum ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax Methods succ :: ScalarStyle -> ScalarStyle pred :: ScalarStyle -> ScalarStyle toEnum :: Int -> ScalarStyle fromEnum :: ScalarStyle -> Int enumFrom :: ScalarStyle -> [ScalarStyle] enumFromThen :: ScalarStyle -> ScalarStyle -> [ScalarStyle] enumFromTo :: ScalarStyle -> ScalarStyle -> [ScalarStyle] enumFromThenTo :: ScalarStyle -> ScalarStyle -> ScalarStyle -> [ScalarStyle] | |||||
| Generic ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax Methods showsPrec :: Int -> ScalarStyle -> ShowS show :: ScalarStyle -> String showList :: [ScalarStyle] -> ShowS | |||||
| Eq ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Ord ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax Methods compare :: ScalarStyle -> ScalarStyle -> Ordering (<) :: ScalarStyle -> ScalarStyle -> Bool (<=) :: ScalarStyle -> ScalarStyle -> Bool (>) :: ScalarStyle -> ScalarStyle -> Bool (>=) :: ScalarStyle -> ScalarStyle -> Bool max :: ScalarStyle -> ScalarStyle -> ScalarStyle min :: ScalarStyle -> ScalarStyle -> ScalarStyle | |||||
| type Rep ScalarStyle Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep ScalarStyle = D1 ('MetaData "ScalarStyle" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) ((C1 ('MetaCons "Plain" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SingleQuoted" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DoubleQuoted" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Literal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Folded" 'PrefixI 'False) (U1 :: Type -> Type)))) | |||||
isBlockScalar :: ScalarStyle -> Bool Source #
The literal or the folded style.
data CollectionStyle Source #
The style of a collection: with indentation, or with brackets and commas.
Instances
Construction
contentNode :: Content -> Node Source #
A node with the given content, without properties and comments.
scalarNode :: ScalarStyle -> Text -> Node Source #
A scalar in the given style. renderSyntax uses quotes if
the style cannot hold the text, and for a block scalar that is a key or an
entry of a flow collection.
>>>T.putStr (renderSyntax defaultRenderOptions [document (mappingNode [(plainNode "key", scalarNode Plain "a: b")])])key: 'a: b'
sequenceNode :: [Node] -> Node Source #
A block sequence.
Comments
The comments and the empty lines that belong to a node.
Constructors
| Comments | |
Fields
| |
Instances
| NFData Comments Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Comments Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Comments Source # | |||||
| Eq Comments Source # | |||||
| Ord Comments Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| type Rep Comments Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Comments = D1 ('MetaData "Comments" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Comments" 'PrefixI 'True) (S1 ('MetaSel ('Just "before") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Line]) :*: (S1 ('MetaSel ('Just "inline") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "after") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Line])))) | |||||
noComments :: Comments Source #
No comments and no empty lines.
withComments :: Comments -> Node -> Node Source #
The node with the comments in place of its own. A record update of the
field is ambiguous where Commented is in scope.
A value with the comments of its mapping entry:
before: the lines above the entry,inline: the comment at the end of the line of the key, or of the line where a value on several lines ends,after: the lines after the value, e.g. after the last entry of a collection.
A Commented value of a mapping entry has the comments of the entry. A
block list or mapping under the key has its own comments: the lines below
the key up to the last empty line above its first entry. A Commented
value inside the first one keeps them, so a type that keeps both nests two
Commented values:
>>>input = "# The CI jobs.\njobs:\n # Run on every push.\n\n # Check the formatting.\n - lint\n"
>>>T.putStr input# The CI jobs. jobs: # Run on every push. # Check the formatting. - lint
>>>Right entries = decodeText @(M.Map T.Text (Commented (Commented [Commented T.Text]))) input>>>Just jobs = M.lookup "jobs" entries
>>>jobs.commentsComments {before = [Comment "The CI jobs."], inline = Nothing, after = []}
>>>jobs.value.commentsComments {before = [Comment "Run on every push.",EmptyLine], inline = Nothing, after = []}
>>>map (.comments) jobs.value.value[Comments {before = [Comment "Check the formatting."], inline = Nothing, after = []}]
A value without a key, e.g. an item of a list, has the comments of its
node. The comments of a list or a mapping stay with it, not with its first
item or key: the lines up to the last empty line above its first entry, and
the comment on its first line, e.g. after its tag. A Commented value of
the whole list or mapping keeps them.
By the rules in Comments, some lines read back with a change:
- The lines after a text of several lines, which the encoder writes as a block scalar, read back as the lines above the next entry. After the last entry, they belong to the end of the collection around the entry.
- The lines above a list or a mapping without a key can get an empty line below them, e.g. at the top level. The empty line reads back as the last of these lines.
- The lines above the first item of a list or the first key of a mapping
that end with an empty line read back as the lines of the list or the
mapping. A
Commentedlist or mapping keeps them. Under a key, the inner of two nestedCommentedvalues keeps them, as above. Otherwise they are lost.
A comment is lost if its node has no place for it, i.e. if the node does
not decode into a node or a Commented value:
- the comments of a key without a Haskell field, e.g. the tag of a constructor;
- a comment at the end of a nested mapping, unless the field that holds
the mapping is
Commented, because a record has no place for the end of its mapping; - the comments of a record's mapping above its first key, e.g. a comment at the top of a file above an empty line;
- the comments of the key for a type such as
data Name = Name (Commented Text)that derives its instances throughGeneric, because a derived instance for one constructor with one field without a name does not give the key of its entry to the value inside. Declare such a type as a newtype and derive its instances withderiving newtype, which gives the key to the value.
In a map, use Commented on the key or on the value, not on both. With
both, the decoder gives the comments of the key to both, and the encoder
writes only those of the value, so a change to the comments of the key is
lost.
A change of the value keeps the comments:
>>>input = "# The port.\nport: 80 # the default\n"
>>>:{either printErrors (T.putStr . encodeText . M.map (fmap (+ 1))) $ decodeText @(M.Map T.Text (Commented Int)) input :} # The port. port: 81 # the default
The order compares the values first and then the comments, e.g. in a set.
Instances
| Functor Commented Source # | |||||
| Foldable Commented Source # | |||||
Defined in Yamlet.Internal.Syntax Methods fold :: Monoid m => Commented m -> m foldMap :: Monoid m => (a -> m) -> Commented a -> m foldMap' :: Monoid m => (a -> m) -> Commented a -> m foldr :: (a -> b -> b) -> b -> Commented a -> b foldr' :: (a -> b -> b) -> b -> Commented a -> b foldl :: (b -> a -> b) -> b -> Commented a -> b foldl' :: (b -> a -> b) -> b -> Commented a -> b foldr1 :: (a -> a -> a) -> Commented a -> a foldl1 :: (a -> a -> a) -> Commented a -> a elem :: Eq a => a -> Commented a -> Bool maximum :: Ord a => Commented a -> a minimum :: Ord a => Commented a -> a | |||||
| Traversable Commented Source # | |||||
| NFData a => NFData (Commented a) Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic (Commented a) Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show a => Show (Commented a) Source # | |||||
| Eq a => Eq (Commented a) Source # | |||||
| Ord a => Ord (Commented a) Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| FromYaml a => FromYaml (Commented a) Source # | The value with the comments of its entry, or of its node if it has no key, copied like every decoded text. | ||||
| ToYaml a => ToYaml (Commented a) Source # | The value with the comments of its entry. The lines above and the comment of the first line go on the key, or on the value without a key. A key keeps its own lines above, or its own comment, if the value has none. The lines after the value replace its own. | ||||
| type Rep (Commented a) Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep (Commented a) = D1 ('MetaData "Commented" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Commented" 'PrefixI 'True) (S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "comments") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Comments))) | |||||
A line of comments.
Constructors
| EmptyLine | |
| CommentLine !Int !Text | The number of The comment at the end of a line in |
Bundled Patterns
| pattern Comment :: Text -> Line | A comment with one |
Instances
| NFData Line Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Line Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Line Source # | |||||
| Eq Line Source # | |||||
| Ord Line Source # | |||||
| type Rep Line Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Line = D1 ('MetaData "Line" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "EmptyLine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CommentLine" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))) | |||||
Positions
The offset of a byte in the input text, in its UTF-8 encoding. For an
input in UTF-16 or UTF-32, the offset counts the bytes of the text after
decodeInput, not the bytes of the input.
Constructors
| Offset Int |
Instances
| NFData Offset Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic Offset Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show Offset Source # | |||||
| Eq Offset Source # | |||||
| Ord Offset Source # | |||||
| type Rep Offset Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep Offset = D1 ('MetaData "Offset" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'True) (C1 ('MetaCons "Offset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) | |||||
A value with the offset of its node, e.g. for the error of a check that runs after the decode. The encoder writes only the value.
documentErrors turns the offsets into errors with lines,
columns and paths. It needs the text and the document of the decode, so
decode with decodeWithDocument. Here the check gives an offset and
a message for each problem:
>>>input = "paths:\n- src\n- /etc\n"
>>>:{case decodeWithDocument @(M.Map T.Text [Located T.Text]) input of Right (config, doc) -> let errs = [ (p.offset, "the path is outside the repository") | p <- concat (M.elems config) , "/" `T.isPrefixOf` p.value ] in printErrors (documentErrors input doc errs) Left errs -> printErrors errs :} input.yaml:3:3: paths[1]: the path is outside the repository | 3 | - /etc | ^
A value that no node gives, e.g. a value of yamlDefault,
has noOffset. Its error has no position, and prettyError
prints only the file and the message. A value inside an alias has the
offset of the alias, i.e. of the place where the document uses the value.
Two equal values at different places are not equal as Located values,
e.g. a set keeps both. The equality and the order compare the values first
and then the offsets. To compare only the values, e.g. in a test, use the
field value.
Instances
| Functor Located Source # | |||||
| Foldable Located Source # | |||||
Defined in Yamlet.Internal.Syntax Methods fold :: Monoid m => Located m -> m foldMap :: Monoid m => (a -> m) -> Located a -> m foldMap' :: Monoid m => (a -> m) -> Located a -> m foldr :: (a -> b -> b) -> b -> Located a -> b foldr' :: (a -> b -> b) -> b -> Located a -> b foldl :: (b -> a -> b) -> b -> Located a -> b foldl' :: (b -> a -> b) -> b -> Located a -> b foldr1 :: (a -> a -> a) -> Located a -> a foldl1 :: (a -> a -> a) -> Located a -> a elem :: Eq a => a -> Located a -> Bool maximum :: Ord a => Located a -> a minimum :: Ord a => Located a -> a | |||||
| Traversable Located Source # | |||||
| NFData a => NFData (Located a) Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| Generic (Located a) Source # | |||||
Defined in Yamlet.Internal.Syntax Associated Types
| |||||
| Show a => Show (Located a) Source # | |||||
| Eq a => Eq (Located a) Source # | |||||
| Ord a => Ord (Located a) Source # | |||||
Defined in Yamlet.Internal.Syntax | |||||
| FromYaml a => FromYaml (Located a) Source # | The value with the offset of its node. The key of an entry goes to the
value inside, e.g. for a | ||||
| ToYaml a => ToYaml (Located a) Source # | The value alone. The key of an entry goes to the value inside, e.g. for a
| ||||
| type Rep (Located a) Source # | |||||
Defined in Yamlet.Internal.Syntax type Rep (Located a) = D1 ('MetaData "Located" "Yamlet.Internal.Syntax" "yamlet-1.0.0.1-2nRkbEnNUrLFBALTocq2AS" 'False) (C1 ('MetaCons "Located" 'PrefixI 'True) (S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "offset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Offset))) | |||||
Copies
copyDocument :: Document -> Document Source #
Copy every text of a document, so that the document does not keep the input alive.
copyNode :: Node -> Node Source #
Copy every text of a node, so that the node does not keep the input alive.
copyComments :: Comments -> Comments Source #