Portability | portable |
---|---|
Stability | provisional |
Maintainer | michael <dot> ilseman <at> gmail <dot> com |
A light-weight wrapper with utility functions around HsSyck
- data YamlLight
- parseYaml :: String -> IO YamlLight
- parseYamlFile :: String -> IO YamlLight
- parseYamlBytes :: ByteString -> IO YamlLight
- fromYamlNode :: YamlNode -> YamlLight
- lookupYL :: YamlLight -> YamlLight -> Maybe YamlLight
- lookupYLWith :: (YamlLight -> Bool) -> YamlLight -> Maybe YamlLight
- combineSequencedMaps :: YamlLight -> Maybe [(YamlLight, YamlLight)]
- unSeq :: YamlLight -> Maybe [YamlLight]
- unMap :: YamlLight -> Maybe (Map YamlLight YamlLight)
- unStr :: YamlLight -> Maybe ByteString
YamlLight data type
A Single, lighter-weight representation than that of HsSyck. Note that the YMap is an actual Map from Data.Map, so behavior with respect to identical keys and ordering of entries will behave as Data.Map dictates. This behavior is also in compliance with the Yaml spec. If you currently rely on HsSyck's preservation of ordering, you can also consider representing such maps as sequences of single entry maps. See the examples of "Ordered Mappings" in the Yaml spec: http://www.yaml.org/spec/1.2/spec.html.
YamlLight versions of Syck functions
parseYamlFile :: String -> IO YamlLightSource
Given a file name, parse contents of file
parseYamlBytes :: ByteString -> IO YamlLightSource
Parse a ByteString buffer (this is faster)
YamlLight utility functions
fromYamlNode :: YamlNode -> YamlLightSource
Convert a Syck YamlNode to a YamlLight
lookupYL :: YamlLight -> YamlLight -> Maybe YamlLightSource
Lookup the key's corresponding value in a Map. Returns Nothing if the YamlLight is not a map, or if the key is not found
lookupYLWith :: (YamlLight -> Bool) -> YamlLight -> Maybe YamlLightSource
General form of lookup. Will return the first element that satisfies predicate p, otherwise Nothing
combineSequencedMaps :: YamlLight -> Maybe [(YamlLight, YamlLight)]Source
Combine a sequence of maps into a list of (key,value) pairs. The ordering of the result preserves the ordering of the sequence, but the ordering of the individual maps is as Data.Map handles it.
Example:
- key1: val1 key2: val2 - key3: val3
Would become:
[(key1,val1),(key2,val2),(key3,val3)]
where key1 and key2 might be arranged differently as Data.Map would arrange them. This does not preserve uniqueness of keys across maps. Any items of the sequence that are not maps will be ignored. Returns Nothing if not called on a Sequence
Extractors
unStr :: YamlLight -> Maybe ByteStringSource
Get the contents of a string