yaml 0.8.25.1 → 0.8.26
raw patch · 4 files changed
+29/−14 lines, 4 filesdep ~basedep ~conduitdep ~resourcet
Dependency ranges changed: base, conduit, resourcet
Files
- ChangeLog.md +8/−0
- Data/Yaml/Parser.hs +15/−8
- exe/json2yaml.hs +3/−3
- yaml.cabal +3/−3
ChangeLog.md view
@@ -1,3 +1,11 @@+## 0.8.26++* Add `Semigroup` instance [#123](https://github.com/snoyberg/yaml/pull/123)++## 0.8.25.2++* Use `throwM` instead of `monadThrow`+ ## 0.8.25.1 * Drop aeson-qq dep (incompatible with Stackage Nightly)
Data/Yaml/Parser.hs view
@@ -9,7 +9,7 @@ import Control.Exception (Exception) import Control.Monad (MonadPlus (..), liftM, ap) import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Resource (MonadThrow, monadThrow, runResourceT)+import Control.Monad.Trans.Resource (MonadThrow, throwM, runResourceT) import Control.Monad.Trans.Writer.Strict (tell, WriterT) import Data.ByteString (ByteString) import Data.Conduit@@ -18,6 +18,9 @@ #if !MIN_VERSION_base(4,8,0) import Data.Monoid (Monoid (..)) #endif+#if !MIN_VERSION_base(4,11,0)+import Data.Semigroup (Semigroup(..))+#endif import Data.Text (Text, pack, unpack) import Data.Text.Encoding (decodeUtf8) import Data.Text.Read (signed, decimal)@@ -36,9 +39,13 @@ instance Alternative YamlParser where empty = fail "empty" (<|>) = mplus+instance Semigroup (YamlParser a) where+ (<>) = mplus instance Monoid (YamlParser a) where mempty = fail "mempty"- mappend = mplus+#if !MIN_VERSION_base(4,11,0)+ mappend = (<>)+#endif instance Monad YamlParser where return = pure YamlParser f >>= g = YamlParser $ \am ->@@ -124,7 +131,7 @@ parseRawDoc :: (FromYaml a, MonadThrow m) => RawDoc -> m a parseRawDoc (RawDoc val am) = case unYamlParser (fromYaml val) am of- Left t -> monadThrow $ FromYamlException t+ Left t -> throwM $ FromYamlException t Right x -> return x (.:) :: FromYaml a => [(Text, YamlValue)] -> Text -> YamlParser a@@ -144,7 +151,7 @@ sinkValue = start where- start = await >>= maybe (monadThrow UnexpectedEndOfEvents) go+ start = await >>= maybe (throwM UnexpectedEndOfEvents) go tell' Nothing val = return val tell' (Just name) val = do@@ -164,12 +171,12 @@ let val = Mapping pairs mname tell' mname val - go e = monadThrow $ UnexpectedEvent e+ go e = throwM $ UnexpectedEvent e goS front = do me <- await case me of- Nothing -> monadThrow UnexpectedEndOfEvents+ Nothing -> throwM UnexpectedEndOfEvents Just EventSequenceEnd -> return $ front [] Just e -> do val <- go e@@ -178,14 +185,14 @@ goM front = do mk <- await case mk of- Nothing -> monadThrow UnexpectedEndOfEvents+ Nothing -> throwM UnexpectedEndOfEvents Just EventMappingEnd -> return $ front [] Just (EventScalar a b c d) -> do _ <- tell' d $ Scalar a b c d let k = decodeUtf8 a v <- start goM (front . ((k, v):))- Just e -> monadThrow $ UnexpectedEvent e+ Just e -> throwM $ UnexpectedEvent e sinkRawDoc :: MonadThrow m => Consumer Event m RawDoc sinkRawDoc = uncurry RawDoc <$> runWriterC sinkValue
exe/json2yaml.hs view
@@ -1,4 +1,3 @@-import Control.Monad (when) import qualified Data.Aeson as J import qualified Data.ByteString as S import qualified Data.ByteString.Lazy as L@@ -9,8 +8,9 @@ main :: IO () main = do args <- getArgs- when (length args > 2) $ error "Usage: json2yaml [in] [out]"- let (input:output:_) = args ++ repeat "-"+ (input, output) <- case args ++ replicate (2 - length args) "-" of+ [i, o] -> return (i, o)+ _ -> fail "Usage: json2yaml [in] [out]" mval <- fmap J.decode $ case input of "-" -> L.getContents
yaml.cabal view
@@ -1,5 +1,5 @@ name: yaml-version: 0.8.25.1+version: 0.8.26 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov@@ -48,8 +48,8 @@ build-depends: base >= 4 && < 5 , transformers >= 0.1 , bytestring >= 0.9.1.4- , conduit >= 1.1.0 && < 1.3- , resourcet >= 0.3 && < 1.2+ , conduit >= 1.1.0 && < 1.4+ , resourcet >= 0.3 && < 1.3 , aeson >= 0.7 , containers , unordered-containers