libyaml-0.1.4: Low-level, streaming YAML interface.

Safe Haskell | None
Language | Haskell2010

Text.Libyaml

Contents

- The event stream
- Encoding and decoding
- Error handling

Description

Low-level, streaming YAML interface. For a higher-level interface, see Data.Yaml.

Synopsis

- data MarkedEvent = MarkedEvent {
  - yamlEvent :: Event
  - yamlStartMark :: YamlMark
  - yamlEndMark :: YamlMark
  }
- data Event
  - = EventStreamStart
  - | EventStreamEnd
  - | EventDocumentStart
  - | EventDocumentEnd
  - | EventAlias !AnchorName
  - | EventScalar !ByteString !Tag !Style !Anchor
  - | EventSequenceStart !Tag !SequenceStyle !Anchor
  - | EventSequenceEnd
  - | EventMappingStart !Tag !MappingStyle !Anchor
  - | EventMappingEnd
- data Style
  - = Any
  - | Plain
  - | SingleQuoted
  - | DoubleQuoted
  - | Literal
  - | Folded
  - | PlainNoTag
- data SequenceStyle
  - = AnySequence
  - | BlockSequence
  - | FlowSequence
- data MappingStyle
  - = AnyMapping
  - | BlockMapping
  - | FlowMapping
- data Tag
  - = StrTag
  - | FloatTag
  - | NullTag
  - | BoolTag
  - | SetTag
  - | IntTag
  - | SeqTag
  - | MapTag
  - | UriTag String
  - | NoTag
- type AnchorName = String
- type Anchor = Maybe AnchorName
- encode :: forall (m :: Type -> Type) o. MonadResource m => ConduitM Event o m ByteString
- encodeWith :: forall (m :: Type -> Type) o. MonadResource m => FormatOptions -> ConduitM Event o m ByteString
- decode :: forall (m :: Type -> Type) i. MonadResource m => ByteString -> ConduitM i Event m ()
- decodeMarked :: forall (m :: Type -> Type) i. MonadResource m => ByteString -> ConduitM i MarkedEvent m ()
- encodeFile :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitM Event o m ()
- decodeFile :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitM i Event m ()
- decodeFileMarked :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitM i MarkedEvent m ()
- encodeFileWith :: forall (m :: Type -> Type) o. MonadResource m => FormatOptions -> FilePath -> ConduitM Event o m ()
- data FormatOptions
- defaultFormatOptions :: FormatOptions
- setWidth :: Maybe Int -> FormatOptions -> FormatOptions
- setTagRendering :: (Event -> TagRender) -> FormatOptions -> FormatOptions
- renderScalarTags :: Event -> TagRender
- renderAllTags :: Event -> TagRender
- renderNoTags :: Event -> TagRender
- renderUriTags :: Event -> TagRender
- data YamlException
  - = YamlException String
  - | YamlParseException {
    - yamlProblem :: String
    - yamlContext :: String
    - yamlProblemMark :: YamlMark
    }
- data YamlMark = YamlMark {
  - yamlIndex :: Int
  - yamlLine :: Int
  - yamlColumn :: Int
  }

# The event stream

data MarkedEvent Source #

Event with start and end marks.

Since: 0.10.4.0

Constructors

MarkedEvent |

Fields

- yamlEvent :: Event
- yamlStartMark :: YamlMark
- yamlEndMark :: YamlMark

data Event Source #

Constructors

EventStreamStart |
EventStreamEnd |
EventDocumentStart |
EventDocumentEnd |
EventAlias !AnchorName |
EventScalar !ByteString !Tag !Style !Anchor |
EventSequenceStart !Tag !SequenceStyle !Anchor |
EventSequenceEnd |
EventMappingStart !Tag !MappingStyle !Anchor |
EventMappingEnd |

#### Instances

Instances details

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

data Style Source #

Style for scalars - e.g. quoted / folded

Constructors

Any |
Plain |
SingleQuoted |
DoubleQuoted |
Literal |
Folded |
PlainNoTag |

#### Instances

Instances details

Data Style Source # |

Instance details

Defined in Text.Libyaml

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Style -> c Style Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Style Source #

toConstr :: Style -> Constr Source #

dataTypeOf :: Style -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Style) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style) Source #

gmapT :: (forall b. Data b => b -> b) -> Style -> Style Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Style -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Style -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Style -> m Style Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style Source #

Bounded Style Source # |
Instance details Defined in Text.Libyaml Methods minBound :: Style Source # maxBound :: Style Source #
Enum Style Source # |
Instance details Defined in Text.Libyaml Methods succ :: Style -> Style Source # pred :: Style -> Style Source # toEnum :: Int -> Style Source # fromEnum :: Style -> Int Source # enumFrom :: Style -> [Style] Source # enumFromThen :: Style -> Style -> [Style] Source # enumFromTo :: Style -> Style -> [Style] Source # enumFromThenTo :: Style -> Style -> Style -> [Style] Source #
Read Style Source # |
Instance details Defined in Text.Libyaml Methods readsPrec :: Int -> ReadS Style Source # readList :: ReadS [Style] Source # readPrec :: ReadPrec Style Source # readListPrec :: ReadPrec [Style] Source #
Show Style Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> Style -> ShowS Source # show :: Style -> String Source # showList :: [Style] -> ShowS Source #
Eq Style Source # |
Instance details Defined in Text.Libyaml Methods (==) :: Style -> Style -> Bool Source # (/=) :: Style -> Style -> Bool Source #
Ord Style Source # |
Instance details Defined in Text.Libyaml Methods compare :: Style -> Style -> Ordering Source # (<) :: Style -> Style -> Bool Source # (<=) :: Style -> Style -> Bool Source # (>) :: Style -> Style -> Bool Source # (>=) :: Style -> Style -> Bool Source # max :: Style -> Style -> Style Source # min :: Style -> Style -> Style Source #

data SequenceStyle Source #

Style for sequences - e.g. block or flow

Since: 0.9.0

Constructors

AnySequence |
BlockSequence |
FlowSequence |

#### Instances

Instances details

Data SequenceStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SequenceStyle -> c SequenceStyle Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SequenceStyle Source #

toConstr :: SequenceStyle -> Constr Source #

dataTypeOf :: SequenceStyle -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SequenceStyle) Source #

gmapT :: (forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SequenceStyle -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle Source #

Bounded SequenceStyle Source # |
Instance details Defined in Text.Libyaml Methods minBound :: SequenceStyle Source # maxBound :: SequenceStyle Source #
Enum SequenceStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

succ :: SequenceStyle -> SequenceStyle Source #

pred :: SequenceStyle -> SequenceStyle Source #

toEnum :: Int -> SequenceStyle Source #

fromEnum :: SequenceStyle -> Int Source #

enumFrom :: SequenceStyle -> [SequenceStyle] Source #

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

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

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

Show SequenceStyle Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> SequenceStyle -> ShowS Source # show :: SequenceStyle -> String Source # showList :: [SequenceStyle] -> ShowS Source #
Eq SequenceStyle Source # |
Instance details Defined in Text.Libyaml Methods (==) :: SequenceStyle -> SequenceStyle -> Bool Source # (/=) :: SequenceStyle -> SequenceStyle -> Bool Source #
Ord SequenceStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

compare :: SequenceStyle -> SequenceStyle -> Ordering Source #

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

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

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

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

max :: SequenceStyle -> SequenceStyle -> SequenceStyle Source #

min :: SequenceStyle -> SequenceStyle -> SequenceStyle Source #

data MappingStyle Source #

Style for mappings - e.g. block or flow

Since: 0.9.0

Constructors

AnyMapping |
BlockMapping |
FlowMapping |

#### Instances

Instances details

Data MappingStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MappingStyle -> c MappingStyle Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MappingStyle Source #

toConstr :: MappingStyle -> Constr Source #

dataTypeOf :: MappingStyle -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MappingStyle) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MappingStyle) Source #

gmapT :: (forall b. Data b => b -> b) -> MappingStyle -> MappingStyle Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> MappingStyle -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MappingStyle -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle Source #

Bounded MappingStyle Source # |
Instance details Defined in Text.Libyaml Methods minBound :: MappingStyle Source # maxBound :: MappingStyle Source #
Enum MappingStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

succ :: MappingStyle -> MappingStyle Source #

pred :: MappingStyle -> MappingStyle Source #

toEnum :: Int -> MappingStyle Source #

fromEnum :: MappingStyle -> Int Source #

enumFrom :: MappingStyle -> [MappingStyle] Source #

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

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

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

Show MappingStyle Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> MappingStyle -> ShowS Source # show :: MappingStyle -> String Source # showList :: [MappingStyle] -> ShowS Source #
Eq MappingStyle Source # |
Instance details Defined in Text.Libyaml Methods (==) :: MappingStyle -> MappingStyle -> Bool Source # (/=) :: MappingStyle -> MappingStyle -> Bool Source #
Ord MappingStyle Source # |

Instance details

Defined in Text.Libyaml

Methods

compare :: MappingStyle -> MappingStyle -> Ordering Source #

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

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

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

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

max :: MappingStyle -> MappingStyle -> MappingStyle Source #

min :: MappingStyle -> MappingStyle -> MappingStyle Source #

data Tag Source #

Constructors

StrTag |
FloatTag |
NullTag |
BoolTag |
SetTag |
IntTag |
SeqTag |
MapTag |
UriTag String |
NoTag |

#### Instances

Instances details

Data Tag Source # |

Instance details

Defined in Text.Libyaml

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Tag -> c Tag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Tag Source #

toConstr :: Tag -> Constr Source #

dataTypeOf :: Tag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Tag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag) Source #

gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Tag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

Read Tag Source # |
Instance details Defined in Text.Libyaml Methods readsPrec :: Int -> ReadS Tag Source # readList :: ReadS [Tag] Source # readPrec :: ReadPrec Tag Source # readListPrec :: ReadPrec [Tag] Source #
Show Tag Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> Tag -> ShowS Source # show :: Tag -> String Source # showList :: [Tag] -> ShowS Source #
Eq Tag Source # |
Instance details Defined in Text.Libyaml Methods (==) :: Tag -> Tag -> Bool Source # (/=) :: Tag -> Tag -> Bool Source #

type AnchorName = String Source #

type Anchor = Maybe AnchorName Source #

# Encoding and decoding

encode :: forall (m :: Type -> Type) o. MonadResource m => ConduitM Event o m ByteString Source #

encodeWith :: forall (m :: Type -> Type) o. MonadResource m => FormatOptions -> ConduitM Event o m ByteString Source #

Since: 0.10.2.0

decode :: forall (m :: Type -> Type) i. MonadResource m => ByteString -> ConduitM i Event m () Source #

Create a conduit that yields events from a bytestring.

decodeMarked :: forall (m :: Type -> Type) i. MonadResource m => ByteString -> ConduitM i MarkedEvent m () Source #

Create a conduit that yields marked events from a bytestring.

This conduit will yield identical events to that of "decode", but also includes start and end marks for each event.

Since: 0.10.4.0

encodeFile :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitM Event o m () Source #

decodeFile :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitM i Event m () Source #

Creata a conduit that yields events from a file.

decodeFileMarked :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitM i MarkedEvent m () Source #

Create a conduit that yields marked events from a file.

This conduit will yield identical events to that of "decodeFile", but also includes start and end marks for each event.

Since: 0.10.4.0

encodeFileWith :: forall (m :: Type -> Type) o. MonadResource m => FormatOptions -> FilePath -> ConduitM Event o m () Source #

Since: 0.10.2.0

data FormatOptions Source #

Contains options relating to the formatting (indendation, width) of the YAML output.

Since: 0.10.2.0

defaultFormatOptions :: FormatOptions Source #

Since: 0.10.2.0

setWidth :: Maybe Int -> FormatOptions -> FormatOptions Source #

Set the maximum number of columns in the YAML output, or `Nothing` for infinite. By default, the limit is 80 characters.

Since: 0.10.2.0

setTagRendering :: (Event -> TagRender) -> FormatOptions -> FormatOptions Source #

Control when and whether tags are rendered to output.

Since: 0.1.1.0

renderScalarTags :: Event -> TagRender Source #

A value for `formatOptionsRenderTags` that renders no collection tags but all scalar tags (unless suppressed with styles 'NoTag or `PlainNoTag`).

Since: 0.1.1.0

renderAllTags :: Event -> TagRender Source #

A value for `formatOptionsRenderTags` that renders all tags (except `NoTag` tag and `PlainNoTag` style).

Since: 0.1.1.0

renderNoTags :: Event -> TagRender Source #

A value for `formatOptionsRenderTags` that renders no tags.

Since: 0.1.1.0

renderUriTags :: Event -> TagRender Source #

A value for `formatOptionsRenderCollectionTags` that renders tags which are instances of `UriTag`

Since: 0.1.1.0

# Error handling

data YamlException Source #

Constructors

YamlException String |
YamlParseException | problem, context, index, position line, position column

Fields

- yamlProblem :: String
- yamlContext :: String
- yamlProblemMark :: YamlMark

#### Instances

Instances details

Exception YamlException Source # |
Instance details Defined in Text.Libyaml Methods toException :: YamlException -> SomeException Source # fromException :: SomeException -> Maybe YamlException Source # displayException :: YamlException -> String Source # backtraceDesired :: YamlException -> Bool Source #
Show YamlException Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> YamlException -> ShowS Source # show :: YamlException -> String Source # showList :: [YamlException] -> ShowS Source #

data YamlMark Source #

The pointer position

Constructors

YamlMark |

Fields

- yamlIndex :: Int
- yamlLine :: Int
- yamlColumn :: Int

#### Instances

Instances details

Show YamlMark Source # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> YamlMark -> ShowS Source # show :: YamlMark -> String Source # showList :: [YamlMark] -> ShowS Source #