HsYAML-0.2.1.5: Pure Haskell YAML 1.2 processor

Copyright | © Herbert Valerio Riedel 2015-2018
License | GPL-2.0-or-later
Safe Haskell | Safe
Language | Haskell2010

Data.YAML.Event

Contents

- Tutorial
  - Parsing YAML Documents
  - Serializing Events to YAML Character Stream
  - How to comment your yaml document for best results
  - Event-stream Internals

Description

Event-stream oriented YAML parsing and serializing API

Synopsis

- parseEvents :: ByteString -> EvStream
- writeEvents :: Encoding -> [Event] -> ByteString
- writeEventsText :: [Event] -> Text
- type EvStream = [Either (Pos, String) EvPos]
- data Event
  - = StreamStart
  - | StreamEnd
  - | DocumentStart !Directives
  - | DocumentEnd !Bool
  - | Comment !Text
  - | Alias !Anchor
  - | Scalar !(Maybe Anchor) !Tag !ScalarStyle !Text
  - | SequenceStart !(Maybe Anchor) !Tag !NodeStyle
  - | SequenceEnd
  - | MappingStart !(Maybe Anchor) !Tag !NodeStyle
  - | MappingEnd
- data EvPos = EvPos {
  - eEvent :: !Event
  - ePos :: !Pos
  }
- data Directives
  - = NoDirEndMarker
  - | DirEndMarkerNoVersion
  - | DirEndMarkerVersion !Word
- data ScalarStyle
  - = Plain
  - | SingleQuoted
  - | DoubleQuoted
  - | Literal !Chomp !IndentOfs
  - | Folded !Chomp !IndentOfs
- data NodeStyle
  - = Flow
  - | Block
- data Chomp
  - = Strip
  - | Clip
  - | Keep
- data IndentOfs
  - = IndentAuto
  - | IndentOfs1
  - | IndentOfs2
  - | IndentOfs3
  - | IndentOfs4
  - | IndentOfs5
  - | IndentOfs6
  - | IndentOfs7
  - | IndentOfs8
  - | IndentOfs9
- data Tag
- untagged :: Tag
- isUntagged :: Tag -> Bool
- tagToText :: Tag -> Maybe Text
- mkTag :: String -> Tag
- type Anchor = Text
- data Pos = Pos {
  - posByteOffset :: !Int
  - posCharOffset :: !Int
  - posLine :: !Int
  - posColumn :: !Int
  }

# Tutorial

Data.YAML module provides us with API which allow us to interact with YAML data at the cost of some presentation details. In contrast, this module provide us with API which gives us access to a other significant details like `ScalarStyle`s, `NodeStyle`s, `Comment`s, etc.

## Parsing YAML Documents

Suppose you want to parse this YAML Document while preserving its format and comments

    # Home runs
    hr:  65
    # Runs Batted In
    rbi: 147

then you might want to use the function `parseEvents`.

The following is a reference implementation of a function using `parseEvents`. It takes a YAML document as input and prints the parsed YAML `Event`s.

    import Data.YAML.Event
    import qualified Data.ByteString.Lazy as BS.L

    printEvents :: BS.L.ByteString -> IO ()
    printEvents input =
      forM_ (parseEvents input) $ ev -> case ev of
        Left _ -> error "Failed to parse"
        Right event -> print (eEvent event)

When we pass the above mentioned YAML document to the function printEvents it outputs the following:

    StreamStart
    DocumentStart NoDirEndMarker
    MappingStart Nothing Nothing Block
    Comment " Home runs"
    Scalar Nothing Nothing Plain "hr"
    Scalar Nothing Nothing Plain "65"
    Comment " Runs Batted In"
    Scalar Nothing Nothing Plain "rbi"
    Scalar Nothing Nothing Plain "147"
    MappingEnd
    DocumentEnd False
    StreamEnd

Notice that now we have all the necessary details in the form of `Event`s.

We can now write simple functions to work with this data without losing any more details.

parseEvents :: ByteString -> EvStream Source #

Parse YAML `Event`s from a lazy `ByteString`.

The parsed Events allow us to round-trip at the event-level while preserving many features and presentation details like `Comment`s,`ScalarStyle`,`NodeStyle`, `Anchor`s, `Directives` marker along with YAML document version, `Chomp`ing Indicator,Indentation Indicator (`IndentOfs`) ,ordering, etc. It does not preserve non-content white spaces.

The input `ByteString` is expected to have a YAML 1.2 stream using the UTF-8, UTF-16 (LE or BE), or UTF-32 (LE or BE) encodings (which will be auto-detected).

## Serializing Events to YAML Character Stream

Now, suppose we want to generate back the YAML document after playing with the Event-stream, then you might want to use `writeEvents`.

The following function takes a YAML document as a input and dumps it back to STDOUT after a round-trip.

    import Data.YAML.Event
    import qualified Data.YAML.Token as YT
    import qualified Data.ByteString.Lazy as BS.L

    yaml2yaml :: BS.L.ByteString -> IO ()
    yaml2yaml input = case sequence $ parseEvents input of
        Left _ -> error "Parsing Failure!"
        Right events -> do
          BS.L.hPutStr stdout (writeEvents YT.UTF8 (map eEvent events))
          hFlush stdout

Let this be the sample document passed to the above function

    # This is a Directives Marker
    ---
    # All Comments are preserved
    date    : 2019-07-12
    bill-to : # Anchor represents a map node
       &id001
        address:
            lines: # This a Block Scalar with Keep chomping Indicator and IndentAuto Indentant indicator
                    |+ # Extra Indentation (non-content white space) will not be preserved
                          Vijay
                          IIT Hyderabad

            # Trailing newlines are a preserved here as they are a part of the Scalar node
            country    : India
    ship-to  : # This is an Alias
               *id001
    # Key is a Scalar and Value is a Sequence
    Other Details:
              total: $ 3000
              # Tags are also preserved
              Online Payment: !!bool True
              product:
                  - Item1
                  # This comment is inside a Sequence
                  - Item2
    ...
    # DocumentEnd True
    # StreamEnd

This function outputs the following

    # This is a Directives Marker
    ---
    # All Comments are preserved
    date: 2019-07-12
    bill-to: # Anchor represents a map node
      &id001
      address:
        lines: # This a Block Scalar with Keep chomping Indicator and IndentAuto Indentant indicator
          # Extra Indentation (non-content white space) will not be preserved
          |+
          Vijay
          IIT Hyderabad

        # Trailing newlines are a preserved here as they are a part of the Scalar node
        country: India
    ship-to: # This is an Alias
      *id001
    # Key is a Scalar and Value is a Sequence
    Other Details:
      total: $ 3000
      # Tags are also preserved
      Online Payment: !!bool True
      product:
      - Item1
      # This comment is inside a Sequence
      - Item2
    ...
    # DocumentEnd True
    # StreamEnd

writeEvents :: Encoding -> [Event] -> ByteString Source #

Serialise `Event`s using specified UTF encoding to a lazy `ByteString`

NOTE: This function is only well-defined for valid `Event` streams

Since: 0.2.0.0

writeEventsText :: [Event] -> Text Source #

Serialise `Event`s to lazy `Text`

NOTE: This function is only well-defined for valid `Event` streams

Since: 0.2.0.0

## How to comment your yaml document for best results

Round-tripping at event-level will preserve all the comments and their relative position in the YAML-document but still, we lose some information like the exact indentation and the position at which the comments were present previously. This information sometimes can be quite important for human-perception of comments. Below are some guildlines, so that you can avoid ambiguities.

1) Always try to start your comment in a newline. This step will avoid most of the ambiguities.

2) Comments automaticly get indented according to the level in which they are present. For example,

Input YAML-document

    # Level 0
    - a
    # Level 0
    - - a
    # Level 1
      - a
      - - a
    # Level 2
        - a

After a round-trip looks like

    # Level 0
    - a
    # Level 0
    - - a
      # Level 1
      - a
      - - a
        # Level 2
        - a

3) Comments immediately after a `Scalar` node, start from a newline. So avoid commenting just after a scalar ends, as it may lead to some ambiguity. For example,

Input YAML-document

    - scalar # After scalar
    - random  : scalar # After scalar
      key: 1
    # not after scalar
    - random  : scalar
      key: 1
    - random  : # not after scalar
                scalar
      # not after scalar
      key: 1

After a round-trip looks like

    - scalar
    # After scalar
    - random: scalar
      # After scalar
      key: 1
      # not after scalar
    - random: scalar
      key: 1
    - random: # not after scalar
        scalar
      # not after scalar
      key: 1

4) Similarly in flow-style, avoid commenting immediately after a comma (`,`) seperator. Comments immediately after a comma (`,`) seperator will start from a new line

Input YAML-document

    {
        # comment 0
        Name: Vijay # comment 1
        ,
        # comment 2
        age: 19, # comment 3
        # comment 4
        country: India # comment 5
    }

After a round-trip looks like

    {
      # comment 0
      Name: Vijay,
      # comment 1
      # comment 2
      age: 19,
      # comment 3
      # comment 4
      country: India,
      # comment 5
    }

5) Avoid commenting in between syntatical elements. For example,

Input YAML-document

    ? # Complex key starts
      [
         a,
         b
      ]
     # Complex key ends
    : # Complex Value starts
      ? # Complex key starts
        [
           a,
           b
        ]
        # Complex key ends
      : # Simple value
        a
      # Complex value ends

After a round-trip looks like

    ? # Complex key starts
      [
         a,
         b
     ]
    : # Complex key ends
      # Complex Value starts

      ? # Complex key starts
        [
           a,
           b
       ]
      : # Complex key ends
        # Simple value
        a
      # Complex value ends

The above two YAML-documents, after parsing produce the same `Event`-stream.

So, these are some limitation of this Format-preserving YAML processor.

## Event-stream Internals

type EvStream = [Either (Pos, String) EvPos] Source #

Event stream produced by `parseEvents`

A `Left` value denotes parsing errors. The event stream ends immediately once a `Left` value is returned.

data Event Source #

YAML Event Types

The events correspond to the ones from LibYAML

The grammar below defines well-formed streams of `Event`s:

    stream   ::= StreamStart document* StreamEnd
    document ::= DocumentStart node DocumentEnd
    node     ::= Alias
               | Scalar
               | Comment
               | sequence
               | mapping
    sequence ::= SequenceStart node* SequenceEnd
    mapping  ::= MappingStart (node node)* MappingEnd

Since: 0.2.0

Constructors

StreamStart |
StreamEnd |
DocumentStart !Directives |
DocumentEnd !Bool |
Comment !Text |
Alias !Anchor |
Scalar !(Maybe Anchor) !Tag !ScalarStyle !Text |
SequenceStart !(Maybe Anchor) !Tag !NodeStyle |
SequenceEnd |
MappingStart !(Maybe Anchor) !Tag !NodeStyle |
MappingEnd |

#### Instances

Instances details

NFData Event Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: Event -> () Source #
Generic Event Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep Event |

Instance details

Defined in Data.YAML.Event.Internal

type Rep Event = D1 ('MetaData "Event" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (((C1 ('MetaCons "StreamStart" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "StreamEnd" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DocumentStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Directives)) :+: (C1 ('MetaCons "DocumentEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Comment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))))) :+: ((C1 ('MetaCons "Alias" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Anchor)) :+: (C1 ('MetaCons "Scalar" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ScalarStyle) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))) :+: C1 ('MetaCons "SequenceStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NodeStyle))))) :+: (C1 ('MetaCons "SequenceEnd" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "MappingStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NodeStyle))) :+: C1 ('MetaCons "MappingEnd" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: Event -> Rep Event x Source #

to :: Rep Event x -> Event Source #

Show Event Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> Event -> ShowS Source # show :: Event -> String Source # showList :: [Event] -> ShowS Source #
Eq Event Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: Event -> Event -> Bool Source # (/=) :: Event -> Event -> Bool Source #
type Rep Event Source # |

Instance details

Defined in Data.YAML.Event.Internal

type Rep Event = D1 ('MetaData "Event" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (((C1 ('MetaCons "StreamStart" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "StreamEnd" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DocumentStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Directives)) :+: (C1 ('MetaCons "DocumentEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Comment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))))) :+: ((C1 ('MetaCons "Alias" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Anchor)) :+: (C1 ('MetaCons "Scalar" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ScalarStyle) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))) :+: C1 ('MetaCons "SequenceStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NodeStyle))))) :+: (C1 ('MetaCons "SequenceEnd" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "MappingStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Anchor)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NodeStyle))) :+: C1 ('MetaCons "MappingEnd" 'PrefixI 'False) (U1 :: Type -> Type)))))

data EvPos Source #

`Event` with corresponding Pos in YAML stream

Since: 0.2.0

Constructors

EvPos |

Fields

- eEvent :: !Event
- ePos :: !Pos

#### Instances

Instances details

NFData EvPos Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: EvPos -> () Source #
Generic EvPos Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep EvPos |
Instance details Defined in Data.YAML.Event.Internal type Rep EvPos = D1 ('MetaData "EvPos" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "EvPos" 'PrefixI 'True) (S1 ('MetaSel ('Just "eEvent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Event) :*: S1 ('MetaSel ('Just "ePos") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos)))

Methods

from :: EvPos -> Rep EvPos x Source #

to :: Rep EvPos x -> EvPos Source #

Show EvPos Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> EvPos -> ShowS Source # show :: EvPos -> String Source # showList :: [EvPos] -> ShowS Source #
Eq EvPos Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: EvPos -> EvPos -> Bool Source # (/=) :: EvPos -> EvPos -> Bool Source #
type Rep EvPos Source # |
Instance details Defined in Data.YAML.Event.Internal type Rep EvPos = D1 ('MetaData "EvPos" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "EvPos" 'PrefixI 'True) (S1 ('MetaSel ('Just "eEvent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Event) :*: S1 ('MetaSel ('Just "ePos") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos)))

data Directives Source #

Encodes document `%YAML` directives and the directives end-marker

Since: 0.2.0

Constructors

NoDirEndMarker | no directives and also no `---` marker
DirEndMarkerNoVersion | `---` marker present, but no explicit `%YAML` directive present
DirEndMarkerVersion !Word | `---` marker present, as well as a `%YAML 1.mi` version directive; the minor version `mi` is stored in the `Word` field.

#### Instances

Instances details

NFData Directives Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: Directives -> () Source #
Generic Directives Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep Directives |

Instance details

Defined in Data.YAML.Event.Internal

type Rep Directives = D1 ('MetaData "Directives" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "NoDirEndMarker" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DirEndMarkerNoVersion" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEndMarkerVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word))))

Methods

from :: Directives -> Rep Directives x Source #

to :: Rep Directives x -> Directives Source #

Show Directives Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> Directives -> ShowS Source # show :: Directives -> String Source # showList :: [Directives] -> ShowS Source #
Eq Directives Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: Directives -> Directives -> Bool Source # (/=) :: Directives -> Directives -> Bool Source #
type Rep Directives Source # |

Instance details

Defined in Data.YAML.Event.Internal

type Rep Directives = D1 ('MetaData "Directives" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "NoDirEndMarker" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DirEndMarkerNoVersion" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DirEndMarkerVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word))))

data ScalarStyle Source #

`Scalar`-specific node style

This can be considered a more granular superset of `NodeStyle`. See also `scalarNodeStyle`.

Since: 0.2.0

Constructors

Plain |
SingleQuoted |
DoubleQuoted |
Literal !Chomp !IndentOfs |
Folded !Chomp !IndentOfs |

#### Instances

Instances details

NFData ScalarStyle Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: ScalarStyle -> () Source #
Generic ScalarStyle Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep ScalarStyle |

Instance details

Defined in Data.YAML.Event.Internal

type Rep ScalarStyle = D1 ('MetaData "ScalarStyle" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" '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) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Chomp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentOfs)) :+: C1 ('MetaCons "Folded" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Chomp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentOfs)))))

Methods

from :: ScalarStyle -> Rep ScalarStyle x Source #

to :: Rep ScalarStyle x -> ScalarStyle Source #

Show ScalarStyle Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> ScalarStyle -> ShowS Source # show :: ScalarStyle -> String Source # showList :: [ScalarStyle] -> ShowS Source #
Eq ScalarStyle Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: ScalarStyle -> ScalarStyle -> Bool Source # (/=) :: ScalarStyle -> ScalarStyle -> Bool Source #
Ord ScalarStyle Source # |

Instance details

Defined in Data.YAML.Event.Internal

Methods

compare :: ScalarStyle -> ScalarStyle -> Ordering Source #

(<) :: ScalarStyle -> ScalarStyle -> Bool Source #

(<=) :: ScalarStyle -> ScalarStyle -> Bool Source #

(>) :: ScalarStyle -> ScalarStyle -> Bool Source #

(>=) :: ScalarStyle -> ScalarStyle -> Bool Source #

max :: ScalarStyle -> ScalarStyle -> ScalarStyle Source #

min :: ScalarStyle -> ScalarStyle -> ScalarStyle Source #

type Rep ScalarStyle Source # |

Instance details

Defined in Data.YAML.Event.Internal

type Rep ScalarStyle = D1 ('MetaData "ScalarStyle" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" '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) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Chomp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentOfs)) :+: C1 ('MetaCons "Folded" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Chomp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentOfs)))))

data NodeStyle Source #

Node style

Since: 0.2.0

Constructors

Flow |
Block |

#### Instances

Instances details

NFData NodeStyle Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: NodeStyle -> () Source #
Generic NodeStyle Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep NodeStyle |
Instance details Defined in Data.YAML.Event.Internal type Rep NodeStyle = D1 ('MetaData "NodeStyle" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Flow" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Block" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: NodeStyle -> Rep NodeStyle x Source #

to :: Rep NodeStyle x -> NodeStyle Source #

Show NodeStyle Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> NodeStyle -> ShowS Source # show :: NodeStyle -> String Source # showList :: [NodeStyle] -> ShowS Source #
Eq NodeStyle Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: NodeStyle -> NodeStyle -> Bool Source # (/=) :: NodeStyle -> NodeStyle -> Bool Source #
Ord NodeStyle Source # |

Instance details

Defined in Data.YAML.Event.Internal

Methods

compare :: NodeStyle -> NodeStyle -> Ordering Source #

(<) :: NodeStyle -> NodeStyle -> Bool Source #

(<=) :: NodeStyle -> NodeStyle -> Bool Source #

(>) :: NodeStyle -> NodeStyle -> Bool Source #

(>=) :: NodeStyle -> NodeStyle -> Bool Source #

max :: NodeStyle -> NodeStyle -> NodeStyle Source #

min :: NodeStyle -> NodeStyle -> NodeStyle Source #

type Rep NodeStyle Source # |
Instance details Defined in Data.YAML.Event.Internal type Rep NodeStyle = D1 ('MetaData "NodeStyle" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Flow" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Block" 'PrefixI 'False) (U1 :: Type -> Type))

data Chomp Source #

Block Chomping Indicator

Since: 0.2.0

Constructors

Strip | Remove all trailing line breaks and shows the presence of `-` chomping indicator.
Clip | Keep first trailing line break; this also the default behavior used if no explicit chomping indicator is specified.
Keep | Keep all trailing line breaks and shows the presence of `+` chomping indicator.

#### Instances

Instances details

NFData Chomp Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: Chomp -> () Source #
Generic Chomp Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep Chomp |
Instance details Defined in Data.YAML.Event.Internal type Rep Chomp = D1 ('MetaData "Chomp" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Strip" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Clip" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Keep" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Chomp -> Rep Chomp x Source #

to :: Rep Chomp x -> Chomp Source #

Show Chomp Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> Chomp -> ShowS Source # show :: Chomp -> String Source # showList :: [Chomp] -> ShowS Source #
Eq Chomp Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: Chomp -> Chomp -> Bool Source # (/=) :: Chomp -> Chomp -> Bool Source #
Ord Chomp Source # |
Instance details Defined in Data.YAML.Event.Internal Methods compare :: Chomp -> Chomp -> Ordering Source # (<) :: Chomp -> Chomp -> Bool Source # (<=) :: Chomp -> Chomp -> Bool Source # (>) :: Chomp -> Chomp -> Bool Source # (>=) :: Chomp -> Chomp -> Bool Source # max :: Chomp -> Chomp -> Chomp Source # min :: Chomp -> Chomp -> Chomp Source #
type Rep Chomp Source # |
Instance details Defined in Data.YAML.Event.Internal type Rep Chomp = D1 ('MetaData "Chomp" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Strip" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Clip" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Keep" 'PrefixI 'False) (U1 :: Type -> Type)))

data IndentOfs Source #

Block Indentation Indicator

`IndentAuto` is the special case for auto Block Indentation Indicator

Since: 0.2.0

Constructors

IndentAuto |
IndentOfs1 |
IndentOfs2 |
IndentOfs3 |
IndentOfs4 |
IndentOfs5 |
IndentOfs6 |
IndentOfs7 |
IndentOfs8 |
IndentOfs9 |

#### Instances

Instances details

NFData IndentOfs Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: IndentOfs -> () Source #
Enum IndentOfs Source # |

Instance details

Defined in Data.YAML.Event.Internal

Methods

succ :: IndentOfs -> IndentOfs Source #

pred :: IndentOfs -> IndentOfs Source #

toEnum :: Int -> IndentOfs Source #

fromEnum :: IndentOfs -> Int Source #

enumFrom :: IndentOfs -> [IndentOfs] Source #

enumFromThen :: IndentOfs -> IndentOfs -> [IndentOfs] Source #

enumFromTo :: IndentOfs -> IndentOfs -> [IndentOfs] Source #

enumFromThenTo :: IndentOfs -> IndentOfs -> IndentOfs -> [IndentOfs] Source #

Generic IndentOfs Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep IndentOfs |

Instance details

Defined in Data.YAML.Event.Internal

type Rep IndentOfs = D1 ('MetaData "IndentOfs" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (((C1 ('MetaCons "IndentAuto" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs1" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IndentOfs2" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IndentOfs3" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs4" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "IndentOfs5" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs6" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IndentOfs7" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IndentOfs8" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs9" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: IndentOfs -> Rep IndentOfs x Source #

to :: Rep IndentOfs x -> IndentOfs Source #

Show IndentOfs Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> IndentOfs -> ShowS Source # show :: IndentOfs -> String Source # showList :: [IndentOfs] -> ShowS Source #
Eq IndentOfs Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: IndentOfs -> IndentOfs -> Bool Source # (/=) :: IndentOfs -> IndentOfs -> Bool Source #
Ord IndentOfs Source # |

Instance details

Defined in Data.YAML.Event.Internal

Methods

compare :: IndentOfs -> IndentOfs -> Ordering Source #

(<) :: IndentOfs -> IndentOfs -> Bool Source #

(<=) :: IndentOfs -> IndentOfs -> Bool Source #

(>) :: IndentOfs -> IndentOfs -> Bool Source #

(>=) :: IndentOfs -> IndentOfs -> Bool Source #

max :: IndentOfs -> IndentOfs -> IndentOfs Source #

min :: IndentOfs -> IndentOfs -> IndentOfs Source #

type Rep IndentOfs Source # |

Instance details

Defined in Data.YAML.Event.Internal

type Rep IndentOfs = D1 ('MetaData "IndentOfs" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (((C1 ('MetaCons "IndentAuto" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs1" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IndentOfs2" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IndentOfs3" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs4" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "IndentOfs5" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs6" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IndentOfs7" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IndentOfs8" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndentOfs9" 'PrefixI 'False) (U1 :: Type -> Type)))))

data Tag Source #

YAML Tags

#### Instances

Instances details

NFData Tag Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Event.Internal Methods rnf :: Tag -> () Source #
Generic Tag Source # |

Instance details

Defined in Data.YAML.Event.Internal

Associated Types

type Rep Tag |
Instance details Defined in Data.YAML.Event.Internal type Rep Tag = D1 ('MetaData "Tag" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'True) (C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text))))

Methods

from :: Tag -> Rep Tag x Source #

to :: Rep Tag x -> Tag Source #

Show Tag Source # |
Instance details Defined in Data.YAML.Event.Internal Methods showsPrec :: Int -> Tag -> ShowS Source # show :: Tag -> String Source # showList :: [Tag] -> ShowS Source #
Eq Tag Source # |
Instance details Defined in Data.YAML.Event.Internal Methods (==) :: Tag -> Tag -> Bool Source # (/=) :: Tag -> Tag -> Bool Source #
Ord Tag Source # |
Instance details Defined in Data.YAML.Event.Internal Methods compare :: Tag -> Tag -> Ordering Source # (<) :: Tag -> Tag -> Bool Source # (<=) :: Tag -> Tag -> Bool Source # (>) :: Tag -> Tag -> Bool Source # (>=) :: Tag -> Tag -> Bool Source # max :: Tag -> Tag -> Tag Source # min :: Tag -> Tag -> Tag Source #
type Rep Tag Source # |
Instance details Defined in Data.YAML.Event.Internal type Rep Tag = D1 ('MetaData "Tag" "Data.YAML.Event.Internal" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'True) (C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text))))

untagged :: Tag Source #

An "untagged" YAML tag

isUntagged :: Tag -> Bool Source #

Equivalent to `(== `untagged`)`

tagToText :: Tag -> Maybe Text Source #

Convert `Tag` to its string representation

Returns `Nothing` for `untagged`

mkTag :: String -> Tag Source #

Construct YAML tag

type Anchor = Text Source #

YAML Anchor identifiers

data Pos Source #

Position in parsed YAML source

See also `prettyPosWithSource`.

NOTE: if `posCharOffset` is negative the `Pos` value doesn't refer to a proper location; this may be emitted in corner cases when no proper location can be inferred.

Constructors

Pos |

Fields

- posByteOffset :: !Int

  0-based byte offset

- posCharOffset :: !Int

  0-based character (Unicode code-point) offset

- posLine :: !Int

  1-based line number

- posColumn :: !Int

  0-based character (Unicode code-point) column number

#### Instances

Instances details

NFData Pos Source # | Since: 0.2.0
Instance details Defined in Data.YAML.Pos Methods rnf :: Pos -> () Source #
Generic Pos Source # |

Instance details

Defined in Data.YAML.Pos

Associated Types

type Rep Pos |

Instance details

Defined in Data.YAML.Pos

type Rep Pos = D1 ('MetaData "Pos" "Data.YAML.Pos" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Pos" 'PrefixI 'True) ((S1 ('MetaSel ('Just "posByteOffset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "posCharOffset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "posLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "posColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))))

Methods

from :: Pos -> Rep Pos x Source #

to :: Rep Pos x -> Pos Source #

Show Pos Source # |
Instance details Defined in Data.YAML.Pos Methods showsPrec :: Int -> Pos -> ShowS Source # show :: Pos -> String Source # showList :: [Pos] -> ShowS Source #
Eq Pos Source # |
Instance details Defined in Data.YAML.Pos Methods (==) :: Pos -> Pos -> Bool Source # (/=) :: Pos -> Pos -> Bool Source #
type Rep Pos Source # |

Instance details

Defined in Data.YAML.Pos

type Rep Pos = D1 ('MetaData "Pos" "Data.YAML.Pos" "HsYAML-0.2.1.5-2leHcaKDSxvGNhtj6ef2D0" 'False) (C1 ('MetaCons "Pos" 'PrefixI 'True) ((S1 ('MetaSel ('Just "posByteOffset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "posCharOffset") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "posLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "posColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))))