Data.Yaml.Parser

yaml-0.8.16: Support for parsing and rendering YAML documents.

Safe Haskell | None
Language | Haskell98

Data.Yaml.Parser

Description

NOTE: This module is a highly experimental preview release. It may change drastically, or be entirely removed, in a future release.

# Documentation

newtype YamlParser a

Constructors

YamlParser |
Fields unYamlParser :: AnchorMap -> Either Text a

Instances

Monad YamlParser |
Functor YamlParser |
Applicative YamlParser |
Alternative YamlParser |
MonadPlus YamlParser |
Monoid (YamlParser a) |

lookupAnchor :: AnchorName -> YamlParser (Maybe YamlValue)

withAnchor :: AnchorName -> Text -> (YamlValue -> YamlParser a) -> YamlParser a

withMapping :: Text -> ([(Text, YamlValue)] -> YamlParser a) -> YamlValue -> YamlParser a

withSequence :: Text -> ([YamlValue] -> YamlParser a) -> YamlValue -> YamlParser a

withText :: Text -> (Text -> YamlParser a) -> YamlValue -> YamlParser a

typeMismatch :: Text -> YamlValue -> YamlParser a

class FromYaml a where

Methods

fromYaml :: YamlValue -> YamlParser a

Instances

FromYaml Int |
FromYaml Text |
FromYaml YamlValue |
FromYaml a => FromYaml [a] |

data YamlValue

Constructors

Mapping [(Text, YamlValue)] Anchor |
Sequence [YamlValue] Anchor |
Scalar ByteString Tag Style Anchor |
Alias AnchorName |

Instances

Show YamlValue |
FromYaml YamlValue |

type AnchorMap = Map AnchorName YamlValue

data RawDoc

Constructors

RawDoc YamlValue AnchorMap |

Instances

Show RawDoc |

parseRawDoc :: (FromYaml a, MonadThrow m) => RawDoc -> m a

(.:) :: FromYaml a => [(Text, YamlValue)] -> Text -> YamlParser a

data YamlParseException

Constructors

UnexpectedEndOfEvents |
UnexpectedEvent Event |
FromYamlException Text |

Instances

Show YamlParseException |
Exception YamlParseException |

sinkValue :: MonadThrow m => Consumer Event (WriterT AnchorMap m) YamlValue

sinkRawDoc :: MonadThrow m => Consumer Event m RawDoc

readYamlFile :: FromYaml a => FilePath -> IO a