commit ghc-yaml for openSUSE:Factory
Hello community,
here is the log from the commit of package ghc-yaml for openSUSE:Factory checked in at 2018-05-30 12:16:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-yaml (Old)
and /work/SRC/openSUSE:Factory/.ghc-yaml.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-yaml"
Wed May 30 12:16:07 2018 rev:27 rq:607958 version:0.8.30
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-yaml/ghc-yaml.changes 2017-09-15 22:27:45.485497850 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-yaml.new/ghc-yaml.changes 2018-05-30 12:28:00.172815882 +0200
@@ -1,0 +2,17 @@
+Mon May 14 17:02:11 UTC 2018 - psimons@suse.com
+
+- Update yaml to version 0.8.30.
+ * Removed `AppSettings` mentioned in `loadYamlSettings` error message.
+ * Deprecated `decodeFile` [#129](https://github.com/snoyberg/yaml/issues/129)
+ * Turn off executables by default [#103](https://github.com/snoyberg/yaml/issues/103)
+ * Add `Data.Yaml.TH.yamlQQ`
+ * Support conduit 1.3
+ * Add `Semigroup` instance [#123](https://github.com/snoyberg/yaml/pull/123)
+ * Use `throwM` instead of `monadThrow`
+ * Drop aeson-qq dep (incompatible with Stackage Nightly)
+ * Tweaks to the executable `yaml2json` [#119](https://github.com/snoyberg/yaml/pull/119):
+ - Add command-line option `-h` and `--help` to show help message
+ - Error messages are now written to `stderr` instead of `stdout`
+ * New encodePretty option `setConfDropNull` to drop null values from objects [#116](https://github.com/snoyberg/yaml/issues/116)
+
+-------------------------------------------------------------------
Old:
----
yaml-0.8.23.3.tar.gz
New:
----
yaml-0.8.30.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-yaml.spec ++++++
--- /var/tmp/diff_new_pack.7InOm0/_old 2018-05-30 12:28:00.920789482 +0200
+++ /var/tmp/diff_new_pack.7InOm0/_new 2018-05-30 12:28:00.924789341 +0200
@@ -1,7 +1,7 @@
#
# spec file for package ghc-yaml
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,14 +19,13 @@
%global pkg_name yaml
%bcond_with tests
Name: ghc-%{pkg_name}
-Version: 0.8.23.3
+Version: 0.8.30
Release: 0
Summary: Support for parsing and rendering YAML documents
License: BSD-3-Clause
Group: Development/Libraries/Haskell
URL: https://hackage.haskell.org/package/%{pkg_name}
Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
-BuildRequires: chrpath
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-aeson-devel
BuildRequires: ghc-attoparsec-devel
@@ -46,7 +45,6 @@
BuildRequires: ghc-vector-devel
%if %{with tests}
BuildRequires: ghc-HUnit-devel
-BuildRequires: ghc-aeson-qq-devel
BuildRequires: ghc-base-compat-devel
BuildRequires: ghc-hspec-devel
BuildRequires: ghc-mockery-devel
@@ -54,7 +52,8 @@
%endif
%description
-Support for parsing and rendering YAML documents.
+README and API documentation are available at
+https://www.stackage.org/package/yaml.
%package devel
Summary: Haskell %{pkg_name} library development files
@@ -75,7 +74,6 @@
%install
%ghc_lib_install
-%ghc_fix_rpath %{pkg_name}-%{version}
%check
%cabal_test
@@ -87,11 +85,9 @@
%ghc_pkg_recache
%files -f %{name}.files
-%doc LICENSE
-%{_bindir}/json2yaml
-%{_bindir}/yaml2json
+%license LICENSE
%files devel -f %{name}-devel.files
-%doc ChangeLog.md README.md examples
+%doc ChangeLog.md README.md
%changelog
++++++ yaml-0.8.23.3.tar.gz -> yaml-0.8.30.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/ChangeLog.md new/yaml-0.8.30/ChangeLog.md
--- old/yaml-0.8.23.3/ChangeLog.md 2017-07-14 09:17:46.000000000 +0200
+++ new/yaml-0.8.30/ChangeLog.md 2018-05-04 07:36:29.000000000 +0200
@@ -1,3 +1,42 @@
+## 0.8.30
+
+* Removed `AppSettings` mentioned in `loadYamlSettings` error message.
+
+## 0.8.29
+
+* Deprecated `decodeFile` [#129](https://github.com/snoyberg/yaml/issues/129)
+* Turn off executables by default [#103](https://github.com/snoyberg/yaml/issues/103)
+
+## 0.8.28
+
+* Add `Data.Yaml.TH.yamlQQ`
+
+## 0.8.27
+
+* Support conduit 1.3
+
+## 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)
+
+## 0.8.25
+
+* Tweaks to the executable `yaml2json` [#119](https://github.com/snoyberg/yaml/pull/119):
+ - Add command-line option `-h` and `--help` to show help message
+ - Error messages are now written to `stderr` instead of `stdout`
+
+## 0.8.24
+
+* New encodePretty option `setConfDropNull` to drop null values from objects [#116](https://github.com/snoyberg/yaml/issues/116)
+
## 0.8.23.3
* Avoid over-escaping `*` [#113](https://github.com/snoyberg/yaml/issues/113)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Builder.hs new/yaml-0.8.30/Data/Yaml/Builder.hs
--- old/yaml-0.8.23.3/Data/Yaml/Builder.hs 2017-06-16 05:46:12.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml/Builder.hs 2018-01-15 18:30:34.000000000 +0100
@@ -21,7 +21,6 @@
import Prelude hiding (null)
import Control.Arrow (second)
-import Control.Monad.Trans.Resource (runResourceT)
#if MIN_VERSION_aeson(1,0,0)
import Data.Aeson.Text (encodeToTextBuilder)
#else
@@ -107,11 +106,11 @@
toEvents (YamlBuilder front) =
EventStreamStart : EventDocumentStart : front [EventDocumentEnd, EventStreamEnd]
-toSource :: (Monad m, ToYaml a) => a -> Source m Event
+toSource :: (Monad m, ToYaml a) => a -> ConduitM i Event m ()
toSource = mapM_ yield . toEvents . toYaml
toByteString :: ToYaml a => a -> ByteString
-toByteString yb = unsafePerformIO $ runResourceT $ toSource yb $$ encode
+toByteString yb = unsafePerformIO $ runConduitRes $ toSource yb .| encode
writeYamlFile :: ToYaml a => FilePath -> a -> IO ()
-writeYamlFile fp yb = runResourceT $ toSource yb $$ encodeFile fp
+writeYamlFile fp yb = runConduitRes $ toSource yb .| encodeFile fp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Config.hs new/yaml-0.8.30/Data/Yaml/Config.hs
--- old/yaml-0.8.23.3/Data/Yaml/Config.hs 2016-06-21 18:51:20.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml/Config.hs 2018-05-04 07:36:29.000000000 +0200
@@ -195,7 +195,7 @@
RequireCustomEnv env -> return $ applyEnvValue True env value'
case fromJSON value of
- Error s -> error $ "Could not convert to AppSettings: " ++ s
+ Error s -> error $ "Could not convert to expected type: " ++ s
Success settings -> return settings
-- | Same as @loadYamlSettings@, but get the list of runtime config files from
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Include.hs new/yaml-0.8.30/Data/Yaml/Include.hs
--- old/yaml-0.8.23.3/Data/Yaml/Include.hs 2017-01-25 12:17:27.000000000 +0100
+++ new/yaml-0.8.30/Data/Yaml/Include.hs 2018-01-15 18:30:34.000000000 +0100
@@ -27,19 +27,19 @@
eventsFromFile
:: MonadResource m
=> FilePath
- -> Producer m Event
+ -> ConduitM i Event m ()
eventsFromFile = go []
where
- go :: MonadResource m => [FilePath] -> FilePath -> Producer m Event
+ go :: MonadResource m => [FilePath] -> FilePath -> ConduitM i Event m ()
go seen fp = do
cfp <- liftIO $ handleNotFound $ canonicalizePath fp
when (cfp `elem` seen) $ do
liftIO $ throwIO CyclicIncludes
- Y.decodeFile cfp $= do
+ Y.decodeFile cfp .| do
awaitForever $ \event -> case event of
EventScalar f (UriTag "!include") _ _ -> do
let includeFile = takeDirectory cfp > unpack (decodeUtf8 f)
- go (cfp : seen) includeFile $= CL.filter (`notElem` irrelevantEvents)
+ go (cfp : seen) includeFile .| CL.filter (`notElem` irrelevantEvents)
_ -> yield event
irrelevantEvents = [EventStreamStart, EventDocumentStart, EventDocumentEnd, EventStreamEnd]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Internal.hs new/yaml-0.8.30/Data/Yaml/Internal.hs
--- old/yaml-0.8.23.3/Data/Yaml/Internal.hs 2017-07-14 09:17:05.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml/Internal.hs 2018-01-15 18:30:34.000000000 +0100
@@ -27,7 +27,7 @@
import qualified Data.Attoparsec.Text as Atto
import Data.ByteString (ByteString)
import Data.Char (toUpper)
-import qualified Data.Conduit as C
+import Data.Conduit ((.|), ConduitM, runConduit)
import qualified Data.Conduit.List as CL
import qualified Data.HashMap.Strict as M
import qualified Data.HashSet as HashSet
@@ -125,12 +125,12 @@
type Parse = StateT (Map.Map String Value) (ResourceT IO)
-requireEvent :: Event -> C.Sink Event Parse ()
+requireEvent :: Event -> ConduitM Event o Parse ()
requireEvent e = do
f <- CL.head
unless (f == Just e) $ liftIO $ throwIO $ UnexpectedEvent f $ Just e
-parse :: C.Sink Event Parse Value
+parse :: ConduitM Event o Parse Value
parse = do
streamStart <- CL.head
case streamStart of
@@ -152,7 +152,7 @@
_ -> liftIO $ throwIO $ UnexpectedEvent streamStart Nothing
parseScalar :: ByteString -> Anchor -> Style -> Tag
- -> C.Sink Event Parse Text
+ -> ConduitM Event o Parse Text
parseScalar v a style tag = do
let res = decodeUtf8With lenientDecode v
case a of
@@ -178,7 +178,7 @@
textToScientific :: Text -> Either String Scientific
textToScientific = Atto.parseOnly (Atto.scientific <* Atto.endOfInput)
-parseO :: C.Sink Event Parse Value
+parseO :: ConduitM Event o Parse Value
parseO = do
me <- CL.head
case me of
@@ -194,7 +194,7 @@
parseS :: Y.Anchor
-> ([Value] -> [Value])
- -> C.Sink Event Parse Value
+ -> ConduitM Event o Parse Value
parseS a front = do
me <- CL.peek
case me of
@@ -212,7 +212,7 @@
parseM :: Y.Anchor
-> M.HashMap Text Value
- -> C.Sink Event Parse Value
+ -> ConduitM Event o Parse Value
parseM a front = do
me <- CL.peek
case me of
@@ -249,13 +249,13 @@
merge' al _ = al
decodeHelper :: FromJSON a
- => C.Source Parse Y.Event
+ => ConduitM () Y.Event Parse ()
-> IO (Either ParseException (Either String a))
decodeHelper src = do
-- This used to be tryAny, but the fact is that catching async
-- exceptions is fine here. We'll rethrow them immediately in the
-- otherwise clause.
- x <- try $ runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
+ x <- try $ runResourceT $ flip evalStateT Map.empty $ runConduit $ src .| parse
case x of
Left e
| Just pe <- fromException e -> return $ Left pe
@@ -264,10 +264,10 @@
Right y -> return $ Right $ parseEither parseJSON y
decodeHelper_ :: FromJSON a
- => C.Source Parse Event
+ => ConduitM () Event Parse ()
-> IO (Either ParseException a)
decodeHelper_ src = do
- x <- try $ runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
+ x <- try $ runResourceT $ flip evalStateT Map.empty $ runConduit $ src .| parse
return $ case x of
Left e
| Just pe <- fromException e -> Left pe
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Parser.hs new/yaml-0.8.30/Data/Yaml/Parser.hs
--- old/yaml-0.8.23.3/Data/Yaml/Parser.hs 2017-06-16 05:46:12.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml/Parser.hs 2018-01-15 18:30:34.000000000 +0100
@@ -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)
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
@@ -140,11 +147,11 @@
deriving (Show, Typeable)
instance Exception YamlParseException
-sinkValue :: MonadThrow m => Consumer Event (WriterT AnchorMap m) YamlValue
+sinkValue :: MonadThrow m => ConduitM Event o (WriterT AnchorMap m) YamlValue
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,17 +185,17 @@
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 :: MonadThrow m => ConduitM Event o m RawDoc
sinkRawDoc = uncurry RawDoc <$> runWriterC sinkValue
readYamlFile :: FromYaml a => FilePath -> IO a
-readYamlFile fp = runResourceT (decodeFile fp $$ sinkRawDoc) >>= parseRawDoc
+readYamlFile fp = runConduitRes (decodeFile fp .| sinkRawDoc) >>= parseRawDoc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/Pretty.hs new/yaml-0.8.30/Data/Yaml/Pretty.hs
--- old/yaml-0.8.23.3/Data/Yaml/Pretty.hs 2016-02-15 10:15:08.000000000 +0100
+++ new/yaml-0.8.30/Data/Yaml/Pretty.hs 2017-10-31 18:05:16.000000000 +0100
@@ -1,12 +1,14 @@
{-# LANGUAGE CPP #-}
-- | Prettier YAML encoding.
--
--- Since 0.8.13
+-- @since 0.8.13
module Data.Yaml.Pretty
( encodePretty
, Config
, getConfCompare
, setConfCompare
+ , getConfDropNull
+ , setConfDropNull
, defConfig
) where
@@ -29,30 +31,47 @@
import Data.Yaml.Builder
-- |
--- Since 0.8.13
+-- @since 0.8.13
data Config = Config
{ confCompare :: Text -> Text -> Ordering -- ^ Function used to sort keys in objects
+ , confDropNull :: Bool
}
--- | The default configuration: do not sort objects.
+-- | The default configuration: do not sort objects or drop keys
--
--- Since 0.8.13
+-- @since 0.8.13
defConfig :: Config
-defConfig = Config mempty
+defConfig = Config mempty False
-- |
--- Since 0.8.13
+-- @since 0.8.13
getConfCompare :: Config -> Text -> Text -> Ordering
getConfCompare = confCompare
--- |
--- Since 0.8.13
+-- | Sets ordering for object keys
+--
+-- @since 0.8.13
setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
setConfCompare cmp c = c { confCompare = cmp }
+-- |
+-- @since 0.8.24
+getConfDropNull :: Config -> Bool
+getConfDropNull = confDropNull
+
+-- | Drop entries with `Null` value from objects, if set to `True`
+--
+-- @since 0.8.24
+setConfDropNull :: Bool -> Config -> Config
+setConfDropNull m c = c { confDropNull = m }
+
pretty :: Config -> Value -> YamlBuilder
pretty cfg = go
- where go (Object o) = mapping (sortBy (confCompare cfg `on` fst) $ HM.toList $ HM.map go o)
+ where go (Object o) = let sort = sortBy (confCompare cfg `on` fst)
+ select
+ | confDropNull cfg = HM.filter (/= Null)
+ | otherwise = id
+ in mapping (sort $ HM.toList $ HM.map go $ select o)
go (Array a) = array (go <$> V.toList a)
go Null = null
go (String s) = string s
@@ -61,6 +80,6 @@
-- | Configurable 'encode'.
--
--- Since 0.8.13
+-- @since 0.8.13
encodePretty :: ToJSON a => Config -> a -> ByteString
encodePretty cfg = toByteString . pretty cfg . toJSON
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml/TH.hs new/yaml-0.8.30/Data/Yaml/TH.hs
--- old/yaml-0.8.23.3/Data/Yaml/TH.hs 2016-10-16 04:44:01.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml/TH.hs 2018-01-16 19:14:25.000000000 +0100
@@ -1,10 +1,13 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TemplateHaskell #-}
module Data.Yaml.TH
( -- * Decoding
- decodeFile
+ yamlQQ
+#if MIN_VERSION_template_haskell(2,9,0)
+ , decodeFile
+#endif
-- * Re-exports from "Data.Yaml"
, Value (..)
, Parser
@@ -19,11 +22,16 @@
, FromJSON (..)
) where
-import Data.Yaml hiding (decodeFile)
-import Language.Haskell.TH
-import Language.Haskell.TH.Syntax
+import Data.Text.Encoding
+import qualified Data.Text as T
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import Language.Haskell.TH.Quote
--- | Decode a @yaml@ file at compile time. Only available on GHC version @7.8.1@
+import Data.Yaml hiding (decodeFile)
+
+#if MIN_VERSION_template_haskell(2,9,0)
+-- | Decode a YAML file at compile time. Only available on GHC version @7.8.1@
-- or higher.
--
-- @since 0.8.19.0
@@ -42,3 +50,37 @@
runIO (decodeFileEither path) >>= \case
Left err -> fail (prettyPrintParseException err)
Right x -> fmap TExp (lift (x :: a))
+#endif
+
+decodeValue :: String -> Either String Value
+decodeValue = decodeEither . encodeUtf8 . T.pack
+
+yamlExp :: String -> Q Exp
+yamlExp input = case decodeValue input of
+ Left err -> fail err
+ Right a -> lift a
+
+-- | A @QuasiQuoter@ for YAML.
+--
+-- @since 0.8.28.0
+--
+-- ==== __Examples__
+--
+-- @
+-- {-\# LANGUAGE QuasiQuotes \#-}
+-- import Data.Yaml.TH
+--
+-- value :: Value
+-- value = [yamlQQ|
+-- name: John Doe
+-- age: 23
+-- |]
+-- @
+yamlQQ :: QuasiQuoter
+yamlQQ = QuasiQuoter {
+ quoteExp = yamlExp
+, quotePat = notDefined "quotePat"
+, quoteType = notDefined "quoteType"
+, quoteDec = notDefined "quoteDec"
+} where
+ notDefined name _ = fail (name ++ " is not defined for yamlQQ")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Data/Yaml.hs new/yaml-0.8.30/Data/Yaml.hs
--- old/yaml-0.8.23.3/Data/Yaml.hs 2017-07-14 09:16:50.000000000 +0200
+++ new/yaml-0.8.30/Data/Yaml.hs 2018-03-19 13:08:47.000000000 +0100
@@ -71,7 +71,6 @@
import Control.Applicative((<$>))
#endif
import Control.Exception
-import Control.Monad.Trans.Resource (runResourceT)
import Data.Aeson
( Value (..), ToJSON (..), FromJSON (..), object
, (.=) , (.:) , (.:?) , (.!=)
@@ -85,7 +84,7 @@
#endif
import Data.Aeson.Types (Pair, parseMaybe, parseEither, Parser)
import Data.ByteString (ByteString)
-import qualified Data.Conduit as C
+import Data.Conduit ((.|), runConduitRes)
import qualified Data.Conduit.List as CL
import qualified Data.HashMap.Strict as M
import qualified Data.HashSet as HashSet
@@ -101,14 +100,14 @@
import qualified Text.Libyaml as Y
encode :: ToJSON a => a -> ByteString
-encode obj = unsafePerformIO $
- runResourceT $ CL.sourceList (objToEvents $ toJSON obj)
- C.$$ Y.encode
+encode obj = unsafePerformIO $ runConduitRes
+ $ CL.sourceList (objToEvents $ toJSON obj)
+ .| Y.encode
encodeFile :: ToJSON a => FilePath -> a -> IO ()
-encodeFile fp obj = runResourceT
- $ CL.sourceList (objToEvents $ toJSON obj)
- C.$$ Y.encodeFile fp
+encodeFile fp obj = runConduitRes
+ $ CL.sourceList (objToEvents $ toJSON obj)
+ .| Y.encodeFile fp
objToEvents :: Value -> [Y.Event]
objToEvents o = (:) EventStreamStart
@@ -166,6 +165,7 @@
=> FilePath
-> IO (Maybe a)
decodeFile fp = decodeHelper (Y.decodeFile fp) >>= either throwIO (return . either (const Nothing) id)
+{-# DEPRECATED decodeFile "Please use decodeFileEither, which does not confused type-directed and runtime exceptions." #-}
-- | A version of 'decodeFile' which should not throw runtime exceptions.
--
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/Text/Libyaml.hs new/yaml-0.8.30/Text/Libyaml.hs
--- old/yaml-0.8.23.3/Text/Libyaml.hs 2017-06-16 05:46:12.000000000 +0200
+++ new/yaml-0.8.30/Text/Libyaml.hs 2018-01-15 18:30:34.000000000 +0100
@@ -479,7 +479,7 @@
deriving (Show, Typeable)
instance Exception ToEventRawException
-decode :: MonadResource m => B.ByteString -> Producer m Event
+decode :: MonadResource m => B.ByteString -> ConduitM i Event m ()
decode bs | B8.null bs = return ()
decode bs =
bracketP alloc cleanup (runParser . fst)
@@ -521,7 +521,7 @@
then withCString openMode $ \openMode' -> c_fdopen fd openMode'
else return nullPtr
-decodeFile :: MonadResource m => FilePath -> Producer m Event
+decodeFile :: MonadResource m => FilePath -> ConduitM i Event m ()
decodeFile file =
bracketP alloc cleanup (runParser . fst)
where
@@ -549,7 +549,7 @@
c_yaml_parser_delete ptr
free ptr
-runParser :: MonadResource m => Parser -> Producer m Event
+runParser :: MonadResource m => Parser -> ConduitM i Event m ()
runParser parser = do
e <- liftIO $ parserParseOne' parser
case e of
@@ -573,7 +573,7 @@
return $ Left $ YamlParseException problem context problemMark
else Right <$> getEvent er
-encode :: MonadResource m => Consumer Event m ByteString
+encode :: MonadResource m => ConduitM Event o m ByteString
encode =
runEmitter alloc close
where
@@ -590,7 +590,7 @@
encodeFile :: MonadResource m
=> FilePath
- -> Consumer Event m ()
+ -> ConduitM Event o m ()
encodeFile filePath =
bracketP getFile c_fclose $ \file -> runEmitter (alloc file) (\u _ -> return u)
where
@@ -605,7 +605,7 @@
runEmitter :: MonadResource m
=> (Emitter -> IO a) -- ^ alloc
-> (() -> a -> IO b) -- ^ close
- -> Consumer Event m b
+ -> ConduitM Event o m b
runEmitter allocI closeI =
bracketP alloc cleanup go
where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/exe/json2yaml.hs new/yaml-0.8.30/exe/json2yaml.hs
--- old/yaml-0.8.23.3/exe/json2yaml.hs 2016-02-15 10:15:08.000000000 +0100
+++ new/yaml-0.8.30/exe/json2yaml.hs 2018-01-15 18:30:34.000000000 +0100
@@ -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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/exe/yaml2json.hs new/yaml-0.8.30/exe/yaml2json.hs
--- old/yaml-0.8.23.3/exe/yaml2json.hs 2016-02-15 10:15:08.000000000 +0100
+++ new/yaml-0.8.30/exe/yaml2json.hs 2017-11-13 08:06:07.000000000 +0100
@@ -5,16 +5,17 @@
import Data.ByteString.Lazy (putStr)
import System.Environment (getArgs)
import System.Exit
+import System.IO (stderr, hPutStrLn)
import Data.Yaml (decodeFileEither, decodeEither')
helpMessage :: IO ()
-helpMessage = putStrLn "yaml2json FILE\n use - as FILE to indicate stdin" >> exitFailure
+helpMessage = putStrLn "Usage: yaml2json FILE\n\nuse '-' as FILE to indicate stdin" >> exitFailure
showJSON :: Show a => Either a Value -> IO b
showJSON ejson =
case ejson of
- Left err -> print err >> exitFailure
+ Left err -> hPutStrLn stderr (show err) >> exitFailure
Right res -> putStr (encode (res :: Value)) >> exitSuccess
main :: IO ()
@@ -22,7 +23,9 @@
args <- getArgs
case args of
-- strict getContents will read in all of stdin at once
+ (["-h"]) -> helpMessage
+ (["--help"]) -> helpMessage
(["-"]) -> getContents >>= showJSON . decodeEither'
([f]) -> decodeFileEither f >>= showJSON
_ -> helpMessage
-
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/libyaml/yaml.h new/yaml-0.8.30/libyaml/yaml.h
--- old/yaml-0.8.23.3/libyaml/yaml.h 2017-06-30 06:02:56.000000000 +0200
+++ new/yaml-0.8.30/libyaml/yaml.h 2017-10-31 18:05:16.000000000 +0100
@@ -1091,7 +1091,7 @@
yaml_error_type_t error;
/** Error description. */
const char *problem;
- /** The byte about which the problem occured. */
+ /** The byte about which the problem occurred. */
size_t problem_offset;
/** The problematic value (@c -1 is none). */
int problem_value;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/test/Data/Yaml/IncludeSpec.hs new/yaml-0.8.30/test/Data/Yaml/IncludeSpec.hs
--- old/yaml-0.8.23.3/test/Data/Yaml/IncludeSpec.hs 2017-01-25 12:17:27.000000000 +0100
+++ new/yaml-0.8.30/test/Data/Yaml/IncludeSpec.hs 2017-12-29 07:47:09.000000000 +0100
@@ -1,10 +1,9 @@
-{-# LANGUAGE QuasiQuotes #-}
+{-# LANGUAGE OverloadedStrings #-}
module Data.Yaml.IncludeSpec (main, spec) where
import Test.Hspec
import Data.List (isPrefixOf)
import Data.Aeson
-import Data.Aeson.QQ
import Data.Yaml (ParseException(InvalidYaml))
import Data.Yaml.Include
import Text.Libyaml (YamlException(YamlException))
@@ -12,28 +11,33 @@
main :: IO ()
main = hspec spec
+asInt :: Int -> Int
+asInt = id
+
spec :: Spec
spec = do
describe "decodeFile" $ do
it "supports includes" $ do
- decodeFile "test/resources/foo.yaml" `shouldReturn` Just [aesonQQ|
- {
- foo: 23,
- bar: {one: 1, two: 2},
- baz: 42
- }
- |]
+ decodeFile "test/resources/foo.yaml" `shouldReturn` Just (object
+ [ "foo" .= asInt 23
+ , "bar" .= object
+ [ "one" .= asInt 1
+ , "two" .= asInt 2
+ ]
+ , "baz" .= asInt 42
+ ])
it "supports recursive includes" $ do
- decodeFile "test/resources/baz.yaml" `shouldReturn` Just [aesonQQ|
- {
- foo: {
- foo: 23,
- bar: {one: 1, two: 2},
- baz: 42
- }
- }
- |]
+ decodeFile "test/resources/baz.yaml" `shouldReturn` Just (object
+ [ "foo" .= object
+ [ "foo" .= asInt 23
+ , "bar" .= object
+ [ "one" .= asInt 1
+ , "two" .= asInt 2
+ ]
+ , "baz" .= asInt 42
+ ]
+ ])
it "aborts on cyclic includes" $ do
(decodeFile "test/resources/loop/foo.yaml" :: IO (Maybe Value)) `shouldThrow` anyException
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/test/Data/Yaml/THSpec.hs new/yaml-0.8.30/test/Data/Yaml/THSpec.hs
--- old/yaml-0.8.23.3/test/Data/Yaml/THSpec.hs 1970-01-01 01:00:00.000000000 +0100
+++ new/yaml-0.8.30/test/Data/Yaml/THSpec.hs 2018-01-16 19:14:25.000000000 +0100
@@ -0,0 +1,17 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE QuasiQuotes #-}
+module Data.Yaml.THSpec (spec) where
+
+import Test.Hspec
+import Data.Aeson
+
+import Data.Yaml.TH
+
+spec :: Spec
+spec = do
+ describe "yamlQQ" $ do
+ it "parses yaml" $ do
+ [yamlQQ|
+ name: John Doe
+ age: 23
+ |] `shouldBe` object ["name" .= String "John Doe", "age" .= Number 23]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/test/Data/YamlSpec.hs new/yaml-0.8.30/test/Data/YamlSpec.hs
--- old/yaml-0.8.23.3/test/Data/YamlSpec.hs 2017-07-14 09:16:04.000000000 +0200
+++ new/yaml-0.8.30/test/Data/YamlSpec.hs 2018-01-16 19:14:25.000000000 +0100
@@ -11,8 +11,7 @@
import Test.HUnit hiding (Test, path)
-import qualified Data.Conduit as C
-import qualified Control.Monad.Trans.Resource as C
+import Data.Conduit (runConduitRes, (.|), ConduitM)
import qualified Data.Conduit.List as CL
import Control.Monad
@@ -172,7 +171,7 @@
, "foo\nbar\nbaz\n"
]
-counter :: Monad m => (Y.Event -> Bool) -> C.Sink Y.Event m Int
+counter :: Monad m => (Y.Event -> Bool) -> ConduitM Y.Event o m Int
counter pred' =
CL.fold (\cnt e -> (if pred' e then 1 else 0) + cnt) 0
@@ -181,7 +180,7 @@
-> Int
-> Assertion
caseHelper yamlString pred' expRes = do
- res <- C.runResourceT $ Y.decode (B8.pack yamlString) C.$$ counter pred'
+ res <- runConduitRes $ Y.decode (B8.pack yamlString) .| counter pred'
res @?= expRes
caseCountScalarsWithAnchor :: Assertion
@@ -218,7 +217,7 @@
caseCountScalars :: Assertion
caseCountScalars = do
- res <- C.runResourceT $ Y.decode yamlBS C.$$ CL.fold adder accum
+ res <- runConduitRes $ Y.decode yamlBS .| CL.fold adder accum
res @?= (7, 1, 2)
where
yamlString = "foo:\n baz: [bin1, bin2, bin3]\nbaz: bazval"
@@ -231,7 +230,7 @@
caseLargestString :: Assertion
caseLargestString = do
- res <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.fold adder accum
+ res <- runConduitRes $ Y.decodeFile filePath .| CL.fold adder accum
res @?= (length expected, expected)
where
expected = "this one is just a little bit bigger than the others"
@@ -251,9 +250,9 @@
caseEncodeDecode :: Assertion
caseEncodeDecode = do
- eList <- C.runResourceT $ Y.decode yamlBS C.$$ CL.consume
- bs <- C.runResourceT $ CL.sourceList eList C.$$ Y.encode
- eList2 <- C.runResourceT $ Y.decode bs C.$$ CL.consume
+ eList <- runConduitRes $ Y.decode yamlBS .| CL.consume
+ bs <- runConduitRes $ CL.sourceList eList .| Y.encode
+ eList2 <- runConduitRes $ Y.decode bs .| CL.consume
map MyEvent eList @=? map MyEvent eList2
where
yamlString = "foo: bar\nbaz:\n - bin1\n - bin2\n"
@@ -261,17 +260,17 @@
caseEncodeDecodeFile :: Assertion
caseEncodeDecodeFile = withFile "" $ \tmpPath -> do
- eList <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
- C.runResourceT $ CL.sourceList eList C.$$ Y.encodeFile tmpPath
- eList2 <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
+ eList <- runConduitRes $ Y.decodeFile filePath .| CL.consume
+ runConduitRes $ CL.sourceList eList .| Y.encodeFile tmpPath
+ eList2 <- runConduitRes $ Y.decodeFile filePath .| CL.consume
map MyEvent eList @=? map MyEvent eList2
where
filePath = "test/largest-string.yaml"
caseInterleave :: Assertion
caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
- () <- C.runResourceT $ Y.decodeFile filePath C.$$ Y.encodeFile tmpPath
- () <- C.runResourceT $ Y.decodeFile tmpPath C.$$ Y.encodeFile tmpPath2
+ () <- runConduitRes $ Y.decodeFile filePath .| Y.encodeFile tmpPath
+ () <- runConduitRes $ Y.decodeFile tmpPath .| Y.encodeFile tmpPath2
f1 <- readFile tmpPath
f2 <- readFile tmpPath2
f1 @=? f2
@@ -280,7 +279,7 @@
caseDecodeInvalidDocument :: Assertion
caseDecodeInvalidDocument = do
- x <- try $ C.runResourceT $ Y.decode yamlBS C.$$ CL.sinkNull
+ x <- try $ runConduitRes $ Y.decode yamlBS .| CL.sinkNull
case x of
Left (_ :: SomeException) -> return ()
Right y -> do
@@ -338,12 +337,12 @@
out1 <- D.decodeFile "accenté/bar.yaml"
out1 @?= Just mySample
- createDirectoryIfMissing True "test/resources/accenté/"
-
- readFile "test/resources/accent/foo.yaml" >>=
- writeFile "test/resources/accenté/foo.yaml"
- out2 <- D.decodeFile "test/resources/accenté/foo.yaml"
- out2 @?= Just mySample
+ c <- readFile "test/resources/accent/foo.yaml"
+ inTempDirectory $ do
+ createDirectoryIfMissing True "test/resources/unicode/accenté/"
+ writeFile "test/resources/unicode/accenté/foo.yaml" c
+ out2 <- D.decodeFile "test/resources/unicode/accenté/foo.yaml"
+ out2 @?= Just mySample
caseEncodeDecodeStrings :: Assertion
caseEncodeDecodeStrings = do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.23.3/yaml.cabal new/yaml-0.8.30/yaml.cabal
--- old/yaml-0.8.23.3/yaml.cabal 2017-07-14 09:17:49.000000000 +0200
+++ new/yaml-0.8.30/yaml.cabal 2018-05-04 07:36:29.000000000 +0200
@@ -1,11 +1,11 @@
name: yaml
-version: 0.8.23.3
+version: 0.8.30
license: BSD3
license-file: LICENSE
author: Michael Snoyman
participants (1)
-
root