yaml-0.8.22: 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 # |
Methods (>>=) :: YamlParser a -> (a -> YamlParser b) -> YamlParser b # (>>) :: YamlParser a -> YamlParser b -> YamlParser b # return :: a -> YamlParser a # fail :: String -> YamlParser a #
Functor YamlParser # |
Methods fmap :: (a -> b) -> YamlParser a -> YamlParser b # (<$) :: a -> YamlParser b -> YamlParser a #
Applicative YamlParser # |
Methods pure :: a -> YamlParser a # (<*>) :: YamlParser (a -> b) -> YamlParser a -> YamlParser b # (*>) :: YamlParser a -> YamlParser b -> YamlParser b # (<*) :: YamlParser a -> YamlParser b -> YamlParser a #
Alternative YamlParser # |
Methods empty :: YamlParser a # (<|>) :: YamlParser a -> YamlParser a -> YamlParser a # some :: YamlParser a -> YamlParser [a] # many :: YamlParser a -> YamlParser [a] #
MonadPlus YamlParser # |
Methods mzero :: YamlParser a # mplus :: YamlParser a -> YamlParser a -> YamlParser a #
Monoid (YamlParser a) # |
Methods mempty :: YamlParser a # mappend :: YamlParser a -> YamlParser a -> YamlParser a # mconcat :: [YamlParser a] -> 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 #

Minimal complete definition

fromYaml

Methods

fromYaml :: YamlValue -> YamlParser a #

Instances

FromYaml Int # |
Methods fromYaml :: YamlValue -> YamlParser Int #
FromYaml Text # |
Methods fromYaml :: YamlValue -> YamlParser Text #
FromYaml YamlValue # |
Methods fromYaml :: YamlValue -> YamlParser YamlValue #
FromYaml a => FromYaml [a] # |
Methods fromYaml :: YamlValue -> YamlParser [a] #

data YamlValue #

Constructors

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

Instances

Show YamlValue # |
Methods showsPrec :: Int -> YamlValue -> ShowS # show :: YamlValue -> String # showList :: [YamlValue] -> ShowS #
FromYaml YamlValue # |
Methods fromYaml :: YamlValue -> YamlParser YamlValue #

type AnchorMap = Map AnchorName YamlValue #

data RawDoc #

Constructors

RawDoc YamlValue AnchorMap |

Instances

Show RawDoc # |
Methods showsPrec :: Int -> RawDoc -> ShowS # show :: RawDoc -> String # showList :: [RawDoc] -> ShowS #

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 # |
Methods showsPrec :: Int -> YamlParseException -> ShowS # show :: YamlParseException -> String # showList :: [YamlParseException] -> ShowS #
Exception YamlParseException # |
Methods toException :: YamlParseException -> SomeException # fromException :: SomeException -> Maybe YamlParseException # displayException :: YamlParseException -> String #

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

sinkRawDoc :: MonadThrow m => Consumer Event m RawDoc #

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