@@ -1,5 +1,4 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE PatternGuards #-}
32{-# LANGUAGE ScopedTypeVariables #-}
43{-# LANGUAGE OverloadedStrings #-}
54-- | Provides a high-level interface for processing YAML files.
@@ -76,6 +75,7 @@ import qualified Data.Text.Lazy as TL
7675import Data.Text.Lazy.Builder (toLazyText)
7776import Data.Aeson.Encode (encodeToTextBuilder)
7877import Control.Monad.Trans.Resource (runResourceT)
78+import Control.Applicative((<$>))
7979
8080import Data.Yaml.Internal
8181
@@ -106,10 +106,10 @@ objToEvents' :: Value -> [Y.Event] -> [Y.Event]
106106--objToEvents' (Scalar s) rest = scalarToEvent s : rest
107107objToEvents' (Array list) rest =
108108 EventSequenceStart Nothing
109− : foldr ($) (EventSequenceEnd : rest) (map objToEvents' $ V.toList list)
109+ : foldr objToEvents' (EventSequenceEnd : rest) (V.toList list)
110110objToEvents' (Object pairs) rest =
111111 EventMappingStart Nothing
112− : foldr ($) (EventMappingEnd : rest) (map pairToEvents $ M.toList pairs)
112+ : foldr pairToEvents (EventMappingEnd : rest) (M.toList pairs)
113113
114114-- Empty strings need special handling to ensure they get quoted. This avoids:
115115-- https://github.com/snoyberg/yaml/issues/24
@@ -138,8 +138,8 @@ decode :: FromJSON a
138138 => ByteString
139139 -> Maybe a
140140decode bs = unsafePerformIO
141− $ fmap (either (const Nothing) id)
142− $ decodeHelper_ (Y.decode bs)
141+ $ either (const Nothing) id
142+ <$> decodeHelper_ (Y.decode bs)
143143
144144decodeFile :: FromJSON a
145145 => FilePath
@@ -157,8 +157,8 @@ decodeFileEither = decodeHelper_ . Y.decodeFile
157157
158158decodeEither :: FromJSON a => ByteString -> Either String a
159159decodeEither bs = unsafePerformIO
160− $ fmap (either (Left . prettyPrintParseException) id)
161− $ decodeHelper (Y.decode bs)
160+ $ either (Left . prettyPrintParseException) id
161+ <$> decodeHelper (Y.decode bs)
162162
163163-- | More helpful version of 'decodeEither' which returns the 'YamlException'.
164164--