packages feed

yaml 0.8.26 → 0.8.27

raw patch · 9 files changed

+58/−57 lines, 9 filesdep ~conduitPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: conduit

API changes (from Hackage documentation)

- Data.Yaml: decodeHelper :: FromJSON a => Source Parse Event -> IO (Either ParseException (Either String a))
+ Data.Yaml: decodeHelper :: FromJSON a => ConduitM () Event Parse () -> IO (Either ParseException (Either String a))
- Data.Yaml.Parser: sinkRawDoc :: MonadThrow m => Consumer Event m RawDoc
+ Data.Yaml.Parser: sinkRawDoc :: MonadThrow m => ConduitM Event o m RawDoc
- Data.Yaml.Parser: sinkValue :: MonadThrow m => Consumer Event (WriterT AnchorMap m) YamlValue
+ Data.Yaml.Parser: sinkValue :: MonadThrow m => ConduitM Event o (WriterT AnchorMap m) YamlValue
- Text.Libyaml: decode :: MonadResource m => ByteString -> Producer m Event
+ Text.Libyaml: decode :: MonadResource m => ByteString -> ConduitM i Event m ()
- Text.Libyaml: decodeFile :: MonadResource m => FilePath -> Producer m Event
+ Text.Libyaml: decodeFile :: MonadResource m => FilePath -> ConduitM i Event m ()
- Text.Libyaml: encode :: MonadResource m => Consumer Event m ByteString
+ Text.Libyaml: encode :: MonadResource m => ConduitM Event o m ByteString
- Text.Libyaml: encodeFile :: MonadResource m => FilePath -> Consumer Event m ()
+ Text.Libyaml: encodeFile :: MonadResource m => FilePath -> ConduitM Event o m ()

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.8.27++* Support conduit 1.3+ ## 0.8.26  * Add `Semigroup` instance [#123](https://github.com/snoyberg/yaml/pull/123)
Data/Yaml.hs view
@@ -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
Data/Yaml/Builder.hs view
@@ -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
Data/Yaml/Include.hs view
@@ -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]
Data/Yaml/Internal.hs view
@@ -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
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, throwM, runResourceT)+import Control.Monad.Trans.Resource (MonadThrow, throwM) import Control.Monad.Trans.Writer.Strict (tell, WriterT) import Data.ByteString (ByteString) import Data.Conduit@@ -147,7 +147,7 @@     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@@ -194,8 +194,8 @@                 goM (front . ((k, v):))             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
Text/Libyaml.hs view
@@ -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
test/Data/YamlSpec.hs view
@@ -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,11 +337,11 @@     out1 <- D.decodeFile "accenté/bar.yaml"     out1 @?= Just mySample -  createDirectoryIfMissing True "test/resources/accenté/"+  createDirectoryIfMissing True "test/resources/unicode/accenté/"    readFile "test/resources/accent/foo.yaml" >>=-    writeFile "test/resources/accenté/foo.yaml"-  out2 <- D.decodeFile "test/resources/accenté/foo.yaml"+    writeFile "test/resources/unicode/accenté/foo.yaml"+  out2 <- D.decodeFile "test/resources/unicode/accenté/foo.yaml"   out2 @?= Just mySample  caseEncodeDecodeStrings :: Assertion
yaml.cabal view
@@ -1,5 +1,5 @@ name:            yaml-version:         0.8.26+version:         0.8.27 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov@@ -48,7 +48,7 @@     build-depends:   base >= 4 && < 5                    , transformers >= 0.1                    , bytestring >= 0.9.1.4-                   , conduit >= 1.1.0 && < 1.4+                   , conduit >= 1.2.8 && < 1.4                    , resourcet >= 0.3 && < 1.3                    , aeson >= 0.7                    , containers