@@ -26,8 +26,18 @@ module Data.Yaml {-# WARNING "GHCJS is not supported yet (will break at runtime
2626#else
2727module Data.Yaml
2828#endif
29− ( -- * Types
30− Value (..)
29+ ( -- * Encoding
30+ encode
31+ , encodeFile
32+ -- * Decoding
33+ , decodeEither'
34+ , decodeFileEither
35+ , decodeThrow
36+ , decodeFileThrow
37+ -- ** More control over decoding
38+ , decodeHelper
39+ -- * Types
40+ , Value (..)
3141 , Parser
3242 , Object
3343 , Array
@@ -55,19 +65,10 @@ module Data.Yaml
5565 -- * Classes
5666 , ToJSON (..)
5767 , FromJSON (..)
58− -- * Encoding/decoding
59− , encode
60− , encodeFile
68+ -- * Deprecated
6169 , decode
6270 , decodeFile
63− -- ** Better error information
6471 , decodeEither
65− , decodeEither'
66− , decodeFileEither
67− , decodeThrow
68− , decodeFileThrow
69− -- ** More control over decoding
70− , decodeHelper
7172 ) where
7273#if !MIN_VERSION_base(4,8,0)
7374import Control.Applicative((<$>))
@@ -103,11 +104,13 @@ import Data.Yaml.Internal
103104import Text.Libyaml hiding (encode, decode, encodeFile, decodeFile)
104105import qualified Text.Libyaml as Y
105106
107+-- | Encode a value into its YAML representation.
106108encode :: ToJSON a => a -> ByteString
107109encode obj = unsafePerformIO $ runConduitRes
108110 $ CL.sourceList (objToEvents $ toJSON obj)
109111 .| Y.encode
110112
113+-- | Encode a value into its YAML representation and save to the given file.
111114encodeFile :: ToJSON a => FilePath -> a -> IO ()
112115encodeFile fp obj = runConduitRes
113116 $ CL.sourceList (objToEvents $ toJSON obj)
@@ -208,6 +211,7 @@ decodeThrow = either throwM return . decodeEither'
208211decodeFileThrow :: (MonadIO m, FromJSON a) => FilePath -> m a
209212decodeFileThrow f = liftIO $ decodeFileEither f >>= either throwIO return
210213
214+-- | Construct a new 'Value' from a list of 'Value's.
211215array :: [Value] -> Value
212216array = Array . V.fromList
213217