@@ -1,5 +1,4 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE PatternGuards #-}
3{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
5-- | Provides a high-level interface for processing YAML files.
4-- | Provides a high-level interface for processing YAML files.
@@ -76,6 +75,7 @@ import qualified Data.Text.Lazy as TL
76import Data.Text.Lazy.Builder (toLazyText)
75import Data.Text.Lazy.Builder (toLazyText)
77import Data.Aeson.Encode (encodeToTextBuilder)
76import Data.Aeson.Encode (encodeToTextBuilder)
78import Control.Monad.Trans.Resource (runResourceT)
77import Control.Monad.Trans.Resource (runResourceT)
78+import Control.Applicative((<$>))
80import Data.Yaml.Internal
80import Data.Yaml.Internal
@@ -106,10 +106,10 @@ objToEvents' :: Value -> [Y.Event] -> [Y.Event]
106--objToEvents' (Scalar s) rest = scalarToEvent s : rest
106--objToEvents' (Scalar s) rest = scalarToEvent s : rest
107objToEvents' (Array list) rest =
107objToEvents' (Array list) rest =
108 EventSequenceStart Nothing
108 EventSequenceStart Nothing
109− : foldr ($) (EventSequenceEnd : rest) (map objToEvents' $ V.toList list)
109+ : foldr objToEvents' (EventSequenceEnd : rest) (V.toList list)
110objToEvents' (Object pairs) rest =
110objToEvents' (Object pairs) rest =
111 EventMappingStart Nothing
111 EventMappingStart Nothing
112− : foldr ($) (EventMappingEnd : rest) (map pairToEvents $ M.toList pairs)
112+ : foldr pairToEvents (EventMappingEnd : rest) (M.toList pairs)
114-- Empty strings need special handling to ensure they get quoted. This avoids:
114-- Empty strings need special handling to ensure they get quoted. This avoids:
115-- https://github.com/snoyberg/yaml/issues/24
115-- https://github.com/snoyberg/yaml/issues/24
@@ -138,8 +138,8 @@ decode :: FromJSON a
138 => ByteString
138 => ByteString
139 -> Maybe a
139 -> Maybe a
140decode bs = unsafePerformIO
140decode bs = unsafePerformIO
141− $ fmap (either (const Nothing) id)
141+ $ either (const Nothing) id
142− $ decodeHelper_ (Y.decode bs)
142+ <$> decodeHelper_ (Y.decode bs)
144decodeFile :: FromJSON a
144decodeFile :: FromJSON a
145 => FilePath
145 => FilePath
@@ -157,8 +157,8 @@ decodeFileEither = decodeHelper_ . Y.decodeFile
158decodeEither :: FromJSON a => ByteString -> Either String a
158decodeEither :: FromJSON a => ByteString -> Either String a
159decodeEither bs = unsafePerformIO
159decodeEither bs = unsafePerformIO
160− $ fmap (either (Left . prettyPrintParseException) id)
160+ $ either (Left . prettyPrintParseException) id
161− $ decodeHelper (Y.decode bs)
161+ <$> decodeHelper (Y.decode bs)
163-- | More helpful version of 'decodeEither' which returns the 'YamlException'.
163-- | More helpful version of 'decodeEither' which returns the 'YamlException'.