Text.Libyaml

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

Safe Haskell | Safe-Inferred
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 :: MonadResource m => ConduitM Event o m ByteString
- encodeWith :: MonadResource m => FormatOptions -> ConduitM Event o m ByteString
- decode :: MonadResource m => ByteString -> ConduitM i Event m ()
- decodeMarked :: MonadResource m => ByteString -> ConduitM i MarkedEvent m ()
- encodeFile :: MonadResource m => FilePath -> ConduitM Event o m ()
- decodeFile :: MonadResource m => FilePath -> ConduitM i Event m ()
- decodeFileMarked :: MonadResource m => FilePath -> ConduitM i MarkedEvent m ()
- encodeFileWith :: 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 #

Event with start and end marks.

Since: 0.10.4.0

Constructors

MarkedEvent |
Fields yamlEvent :: Event yamlStartMark :: YamlMark yamlEndMark :: YamlMark

data Event #

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

data Style #

Style for scalars - e.g. quoted / folded

Constructors

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

#### Instances

Instances details

Data Style # |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Style toConstr :: Style -> Constr dataTypeOf :: Style -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Style) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style) gmapT :: (forall b. Data b => b -> b) -> Style -> Style gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r gmapQ :: (forall d. Data d => d -> u) -> Style -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Style -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Style -> m Style gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style
Bounded Style # |
Instance details Defined in Text.Libyaml Methods minBound :: Style maxBound :: Style
Enum Style # |
Instance details Defined in Text.Libyaml Methods succ :: Style -> Style pred :: Style -> Style toEnum :: Int -> Style fromEnum :: Style -> Int enumFrom :: Style -> [Style] enumFromThen :: Style -> Style -> [Style] enumFromTo :: Style -> Style -> [Style] enumFromThenTo :: Style -> Style -> Style -> [Style]
Read Style # |
Instance details Defined in Text.Libyaml Methods readsPrec :: Int -> ReadS Style readList :: ReadS [Style] readPrec :: ReadPrec Style readListPrec :: ReadPrec [Style]
Show Style # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> Style -> ShowS show :: Style -> String showList :: [Style] -> ShowS
Eq Style # |
Instance details Defined in Text.Libyaml Methods (==) :: Style -> Style -> Bool (/=) :: Style -> Style -> Bool
Ord Style # |
Instance details Defined in Text.Libyaml Methods compare :: Style -> Style -> Ordering (<) :: Style -> Style -> Bool (<=) :: Style -> Style -> Bool (>) :: Style -> Style -> Bool (>=) :: Style -> Style -> Bool max :: Style -> Style -> Style min :: Style -> Style -> Style

data SequenceStyle #

Style for sequences - e.g. block or flow

Since: 0.9.0

Constructors

AnySequence |
BlockSequence |
FlowSequence |

#### Instances

Instances details

Data SequenceStyle # |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SequenceStyle toConstr :: SequenceStyle -> Constr dataTypeOf :: SequenceStyle -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SequenceStyle) gmapT :: (forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r gmapQ :: (forall d. Data d => d -> u) -> SequenceStyle -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
Bounded SequenceStyle # |
Instance details Defined in Text.Libyaml Methods minBound :: SequenceStyle maxBound :: SequenceStyle
Enum SequenceStyle # |
Instance details Defined in Text.Libyaml Methods succ :: SequenceStyle -> SequenceStyle pred :: SequenceStyle -> SequenceStyle toEnum :: Int -> SequenceStyle fromEnum :: SequenceStyle -> Int enumFrom :: SequenceStyle -> [SequenceStyle] enumFromThen :: SequenceStyle -> SequenceStyle -> [SequenceStyle] enumFromTo :: SequenceStyle -> SequenceStyle -> [SequenceStyle] enumFromThenTo :: SequenceStyle -> SequenceStyle -> SequenceStyle -> [SequenceStyle]
Show SequenceStyle # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> SequenceStyle -> ShowS show :: SequenceStyle -> String showList :: [SequenceStyle] -> ShowS
Eq SequenceStyle # |
Instance details Defined in Text.Libyaml Methods (==) :: SequenceStyle -> SequenceStyle -> Bool (/=) :: SequenceStyle -> SequenceStyle -> Bool
Ord SequenceStyle # |
Instance details Defined in Text.Libyaml Methods compare :: SequenceStyle -> SequenceStyle -> Ordering (<) :: SequenceStyle -> SequenceStyle -> Bool (<=) :: SequenceStyle -> SequenceStyle -> Bool (>) :: SequenceStyle -> SequenceStyle -> Bool (>=) :: SequenceStyle -> SequenceStyle -> Bool max :: SequenceStyle -> SequenceStyle -> SequenceStyle min :: SequenceStyle -> SequenceStyle -> SequenceStyle

data MappingStyle #

Style for mappings - e.g. block or flow

Since: 0.9.0

Constructors

AnyMapping |
BlockMapping |
FlowMapping |

#### Instances

Instances details

Data MappingStyle # |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MappingStyle toConstr :: MappingStyle -> Constr dataTypeOf :: MappingStyle -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MappingStyle) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MappingStyle) gmapT :: (forall b. Data b => b -> b) -> MappingStyle -> MappingStyle gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r gmapQ :: (forall d. Data d => d -> u) -> MappingStyle -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> MappingStyle -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
Bounded MappingStyle # |
Instance details Defined in Text.Libyaml Methods minBound :: MappingStyle maxBound :: MappingStyle
Enum MappingStyle # |
Instance details Defined in Text.Libyaml Methods succ :: MappingStyle -> MappingStyle pred :: MappingStyle -> MappingStyle toEnum :: Int -> MappingStyle fromEnum :: MappingStyle -> Int enumFrom :: MappingStyle -> [MappingStyle] enumFromThen :: MappingStyle -> MappingStyle -> [MappingStyle] enumFromTo :: MappingStyle -> MappingStyle -> [MappingStyle] enumFromThenTo :: MappingStyle -> MappingStyle -> MappingStyle -> [MappingStyle]
Show MappingStyle # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> MappingStyle -> ShowS show :: MappingStyle -> String showList :: [MappingStyle] -> ShowS
Eq MappingStyle # |
Instance details Defined in Text.Libyaml Methods (==) :: MappingStyle -> MappingStyle -> Bool (/=) :: MappingStyle -> MappingStyle -> Bool
Ord MappingStyle # |
Instance details Defined in Text.Libyaml Methods compare :: MappingStyle -> MappingStyle -> Ordering (<) :: MappingStyle -> MappingStyle -> Bool (<=) :: MappingStyle -> MappingStyle -> Bool (>) :: MappingStyle -> MappingStyle -> Bool (>=) :: MappingStyle -> MappingStyle -> Bool max :: MappingStyle -> MappingStyle -> MappingStyle min :: MappingStyle -> MappingStyle -> MappingStyle

data Tag #

Constructors

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

#### Instances

Instances details

Data Tag # |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Tag toConstr :: Tag -> Constr dataTypeOf :: Tag -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Tag) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag) gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r gmapQ :: (forall d. Data d => d -> u) -> Tag -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Tag -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tag -> m Tag gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag
Read Tag # |
Instance details Defined in Text.Libyaml Methods readsPrec :: Int -> ReadS Tag readList :: ReadS [Tag] readPrec :: ReadPrec Tag readListPrec :: ReadPrec [Tag]
Show Tag # |
Instance details Defined in Text.Libyaml Methods showsPrec :: Int -> Tag -> ShowS show :: Tag -> String showList :: [Tag] -> ShowS
Eq Tag # |
Instance details Defined in Text.Libyaml Methods (==) :: Tag -> Tag -> Bool (/=) :: Tag -> Tag -> Bool

type AnchorName = String #

type Anchor = Maybe AnchorName #

# Encoding and decoding

encode :: MonadResource m => ConduitM Event o m ByteString #

encodeWith :: MonadResource m => FormatOptions -> ConduitM Event o m ByteString #

Since: 0.10.2.0

decode :: MonadResource m => ByteString -> ConduitM i Event m () #

Create a conduit that yields events from a bytestring.

decodeMarked :: MonadResource m => ByteString -> ConduitM i MarkedEvent m () #

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 :: MonadResource m => FilePath -> ConduitM Event o m () #

decodeFile :: MonadResource m => FilePath -> ConduitM i Event m () #

Creata a conduit that yields events from a file.

decodeFileMarked :: MonadResource m => FilePath -> ConduitM i MarkedEvent m () #

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 :: MonadResource m => FormatOptions -> FilePath -> ConduitM Event o m () #

Since: 0.10.2.0

data FormatOptions #

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

Since: 0.10.2.0

defaultFormatOptions :: FormatOptions #

Since: 0.10.2.0

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

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 #

Control when and whether tags are rendered to output.

Since: 0.1.1.0

renderScalarTags :: Event -> TagRender #

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 #

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

Since: 0.1.1.0

renderNoTags :: Event -> TagRender #

A value for `formatOptionsRenderTags` that renders no tags.

Since: 0.1.1.0

renderUriTags :: Event -> TagRender #

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

Since: 0.1.1.0

# Error handling

data YamlException #

Constructors

YamlException String |
YamlParseException | problem, context, index, position line, position column
Fields yamlProblem :: String yamlContext :: String yamlProblemMark :: YamlMark

#### Instances

Instances details

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

data YamlMark #

The pointer position

Constructors

YamlMark |
Fields yamlIndex :: Int yamlLine :: Int yamlColumn :: Int

#### Instances

Instances details

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