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

Safe HaskellNone

Data.Yaml

Contents

Description

Provides a high-level interface for processing YAML files.

This module reuses most of the infrastructure from the aeson package. This means that you can use all of the existing tools for JSON processing for processing YAML files. As a result, much of the documentation below mentions JSON; do not let that confuse you, it's intentional.

For the most part, YAML content translates directly into JSON, and therefore there is very little data loss. If you need to deal with YAML more directly (e.g., directly deal with aliases), you should use the Text.Libyaml module instead.

For documentation on the aeson types, functions, classes, and operators, please see the Data.Aeson module of the aeson package.

Synopsis

Types

data Value

Constructors

Object !Object 
Array !Array 
String !Text 
Number !Number 
Bool !Bool 
Null 

Instances

Eq Value 
Show Value 
Typeable Value 
IsString Value 
Hashable Value 
NFData Value 
ToJSON Value 
FromJSON Value 

data Parser a

Instances

Monad Parser 
Functor Parser 
MonadPlus Parser 
Applicative Parser 
Alternative Parser 
Monoid (Parser a) 

data ParseException

Instances

Show ParseException 
Typeable ParseException 
Exception ParseException 

data YamlException

Constructors

YamlException String 
YamlParseException

problem, context, index, position line, position column

Fields

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

Instances

Show YamlException 
Typeable YamlException 
Exception YamlException 

data YamlMark

The pointer position

Constructors

YamlMark 

Fields

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

Instances

Show YamlMark 

Constructors and accessors

object :: [Pair] -> Value

array :: [Value] -> Value

(.=) :: ToJSON a => Text -> a -> Pair

(.:) :: FromJSON a => Object -> Text -> Parser a

(.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a)

(.!=) :: Parser (Maybe a) -> a -> Parser a

Parsing

parseMonad :: Monad m => (a -> Parser b) -> a -> m b

parseEither :: (a -> Parser b) -> a -> Either String b

parseMaybe :: (a -> Parser b) -> a -> Maybe b

Classes

class ToJSON a where

Methods

toJSON :: a -> Value

Instances

ToJSON Bool 
ToJSON Char 
ToJSON Double 
ToJSON Float 
ToJSON Int 
ToJSON Int8 
ToJSON Int16 
ToJSON Int32 
ToJSON Int64 
ToJSON Integer 
ToJSON Word 
ToJSON Word8 
ToJSON Word16 
ToJSON Word32 
ToJSON Word64 
ToJSON () 
ToJSON ByteString 
ToJSON ByteString 
ToJSON Text 
ToJSON Number 
ToJSON Text 
ToJSON Value 
ToJSON DotNetTime 
ToJSON ZonedTime 
ToJSON IntSet 
ToJSON UTCTime 
ToJSON [Char] 
ToJSON a => ToJSON [a] 
ToJSON (Ratio Integer) 
ToJSON a => ToJSON (Maybe a) 
ToJSON a => ToJSON (First a) 
ToJSON a => ToJSON (Last a) 
ToJSON a => ToJSON (Dual a) 
ToJSON a => ToJSON (HashSet a) 
ToJSON a => ToJSON (Vector a) 
(Vector Vector a, ToJSON a) => ToJSON (Vector a) 
(Storable a, ToJSON a) => ToJSON (Vector a) 
(Prim a, ToJSON a) => ToJSON (Vector a) 
ToJSON a => ToJSON (IntMap a) 
ToJSON a => ToJSON (Set a) 
HasResolution a => ToJSON (Fixed a) 
(ToJSON a, ToJSON b) => ToJSON (Either a b) 
(ToJSON a, ToJSON b) => ToJSON (a, b) 
ToJSON v => ToJSON (HashMap String v) 
ToJSON v => ToJSON (HashMap ByteString v) 
ToJSON v => ToJSON (HashMap ByteString v) 
ToJSON v => ToJSON (HashMap Text v) 
ToJSON v => ToJSON (HashMap Text v) 
ToJSON v => ToJSON (Map String v) 
ToJSON v => ToJSON (Map ByteString v) 
ToJSON v => ToJSON (Map ByteString v) 
ToJSON v => ToJSON (Map Text v) 
ToJSON v => ToJSON (Map Text v) 
(ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) 
(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) 

class FromJSON a where

Methods

parseJSON :: Value -> Parser a

Instances

FromJSON Bool 
FromJSON Char 
FromJSON Double 
FromJSON Float 
FromJSON Int 
FromJSON Int8 
FromJSON Int16 
FromJSON Int32 
FromJSON Int64 
FromJSON Integer 
FromJSON Word 
FromJSON Word8 
FromJSON Word16 
FromJSON Word32 
FromJSON Word64 
FromJSON () 
FromJSON ByteString 
FromJSON ByteString 
FromJSON Text 
FromJSON Number 
FromJSON Text 
FromJSON Value 
FromJSON DotNetTime 
FromJSON ZonedTime 
FromJSON IntSet 
FromJSON UTCTime 
FromJSON [Char] 
FromJSON a => FromJSON [a] 
FromJSON (Ratio Integer) 
FromJSON a => FromJSON (Maybe a) 
FromJSON a => FromJSON (First a) 
FromJSON a => FromJSON (Last a) 
FromJSON a => FromJSON (Dual a) 
(Eq a, Hashable a, FromJSON a) => FromJSON (HashSet a) 
FromJSON a => FromJSON (Vector a) 
(Vector Vector a, FromJSON a) => FromJSON (Vector a) 
(Storable a, FromJSON a) => FromJSON (Vector a) 
(Prim a, FromJSON a) => FromJSON (Vector a) 
FromJSON a => FromJSON (IntMap a) 
(Ord a, FromJSON a) => FromJSON (Set a) 
HasResolution a => FromJSON (Fixed a) 
(FromJSON a, FromJSON b) => FromJSON (Either a b) 
(FromJSON a, FromJSON b) => FromJSON (a, b) 
FromJSON v => FromJSON (HashMap String v) 
FromJSON v => FromJSON (HashMap ByteString v) 
FromJSON v => FromJSON (HashMap ByteString v) 
FromJSON v => FromJSON (HashMap Text v) 
FromJSON v => FromJSON (HashMap Text v) 
FromJSON v => FromJSON (Map String v) 
FromJSON v => FromJSON (Map ByteString v) 
FromJSON v => FromJSON (Map ByteString v) 
FromJSON v => FromJSON (Map Text v) 
FromJSON v => FromJSON (Map Text v) 
(FromJSON a, FromJSON b, FromJSON c) => FromJSON (a, b, c) 
(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON (a, b, c, d) 

Encoding/decoding

encode :: ToJSON a => a -> ByteString

encodeFile :: ToJSON a => FilePath -> a -> IO ()

decode :: FromJSON a => ByteString -> Maybe a

decodeFile :: FromJSON a => FilePath -> IO (Maybe a)

Better error information

decodeEither :: FromJSON a => ByteString -> Either String a

decodeEither' :: FromJSON a => ByteString -> Either ParseException a

More helpful version of decodeEither which returns the YamlException.

Since 0.8.3

decodeFileEither :: FromJSON a => FilePath -> IO (Either ParseException a)

A version of decodeFile which should not throw runtime exceptions.

Since 0.8.4

More control over decoding

decodeHelper :: FromJSON a => Source Parse Event -> IO (Either ParseException (Either String a))