on master help sign in
conduit 1.1 support
aa154a5Michael Snoyman
Data/Yaml.hs+6−5
@@ -91,14 +91,15 @@ import Data.Scientific (fromFloatDigits)
91#else
91#else
92import Data.Attoparsec.Number
92import Data.Attoparsec.Number
93#endif
93#endif
94+import Control.Monad.Trans.Resource (ResourceT, runResourceT)
94
95
95encode :: ToJSON a => a -> ByteString
96encode :: ToJSON a => a -> ByteString
96encode obj = unsafePerformIO $
97encode obj = unsafePerformIO $
97− C.runResourceT $ CL.sourceList (objToEvents $ toJSON obj)
98+ runResourceT $ CL.sourceList (objToEvents $ toJSON obj)
98 C.$$ Y.encode
99 C.$$ Y.encode
99
100
100encodeFile :: ToJSON a => FilePath -> a -> IO ()
101encodeFile :: ToJSON a => FilePath -> a -> IO ()
101−encodeFile fp obj = C.runResourceT
102+encodeFile fp obj = runResourceT
102 $ CL.sourceList (objToEvents $ toJSON obj)
103 $ CL.sourceList (objToEvents $ toJSON obj)
103 C.$$ Y.encodeFile fp
104 C.$$ Y.encodeFile fp
104
105
@@ -187,7 +188,7 @@ instance MonadTrans PErrorT where
187instance MonadIO m => MonadIO (PErrorT m) where
188instance MonadIO m => MonadIO (PErrorT m) where
188 liftIO = lift . liftIO
189 liftIO = lift . liftIO
189
190
190−type Parse = StateT (Map.Map String Value) (C.ResourceT IO)
191+type Parse = StateT (Map.Map String Value) (ResourceT IO)
191
192
192requireEvent :: Event -> C.Sink Event Parse ()
193requireEvent :: Event -> C.Sink Event Parse ()
193requireEvent e = do
194requireEvent e = do
@@ -320,7 +321,7 @@ decodeFileEither
320 => FilePath
321 => FilePath
321 -> IO (Either ParseException a)
322 -> IO (Either ParseException a)
322decodeFileEither fp = do
323decodeFileEither fp = do
323− x <- try $ C.runResourceT $ flip evalStateT Map.empty $ Y.decodeFile fp C.$$ parse
324+ x <- try $ runResourceT $ flip evalStateT Map.empty $ Y.decodeFile fp C.$$ parse
324 case x of
325 case x of
325 Left e
326 Left e
326 | Just pe <- fromException e -> return $ Left pe
327 | Just pe <- fromException e -> return $ Left pe
@@ -356,7 +357,7 @@ decodeHelper :: FromJSON a
356 => C.Source Parse Y.Event
357 => C.Source Parse Y.Event
357 -> IO (Either ParseException (Either String a))
358 -> IO (Either ParseException (Either String a))
358decodeHelper src = do
359decodeHelper src = do
359− x <- try $ C.runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
360+ x <- try $ runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
360 case x of
361 case x of
361 Left e
362 Left e
362 | Just pe <- fromException e -> return $ Left pe
363 | Just pe <- fromException e -> return $ Left pe
Data/Yaml/Builder.hs+1
@@ -22,6 +22,7 @@ import qualified Data.Conduit.List as CL
22import System.IO.Unsafe (unsafePerformIO)
22import System.IO.Unsafe (unsafePerformIO)
23import Control.Arrow (second)
23import Control.Arrow (second)
24import qualified Data.ByteString.Char8 as S8
24import qualified Data.ByteString.Char8 as S8
25+import Control.Monad.Trans.Resource (runResourceT)
25
26
26(.=) :: ToYaml a => Text -> a -> (Text, YamlBuilder)
27(.=) :: ToYaml a => Text -> a -> (Text, YamlBuilder)
27k .= v = (k, toYaml v)
28k .= v = (k, toYaml v)
Data/Yaml/Parser.hs+7
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
3-- | NOTE: This module is a highly experimental preview release. It may change
4-- | NOTE: This module is a highly experimental preview release. It may change
@@ -10,9 +11,15 @@ import Data.Monoid (Monoid (..))
10import Control.Monad (MonadPlus (..), liftM, ap)
11import Control.Monad (MonadPlus (..), liftM, ap)
11import Control.Monad.Trans.Writer.Strict (tell, WriterT)
12import Control.Monad.Trans.Writer.Strict (tell, WriterT)
12import Control.Monad.Trans.Class (lift)
13import Control.Monad.Trans.Class (lift)
14+import Control.Monad.Trans.Resource (MonadThrow, monadThrow, runResourceT)
13import qualified Data.Map as Map
15import qualified Data.Map as Map
14import Data.Conduit
16import Data.Conduit
17+#if MIN_VERSION_conduit(1,1,0)
18+import Data.Conduit.Lift (runWriterC)
19+#define runWriterSC runWriterC
20+#else
15import Data.Conduit.Lift (runWriterSC)
21import Data.Conduit.Lift (runWriterSC)
22+#endif
16import Data.Text (Text, pack, unpack)
23import Data.Text (Text, pack, unpack)
17import Data.Text.Encoding (decodeUtf8)
24import Data.Text.Encoding (decodeUtf8)
18import Data.ByteString (ByteString)
25import Data.ByteString (ByteString)
yaml.cabal+3−3
@@ -1,5 +1,5 @@
1name: yaml
1name: yaml
2−version: 0.8.8
2+version: 0.8.8.1
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov
@@ -41,8 +41,8 @@ library
41 build-depends: base >= 4 && < 5
41 build-depends: base >= 4 && < 5
42 , transformers >= 0.1 && < 0.4
42 , transformers >= 0.1 && < 0.4
43 , bytestring >= 0.9.1.4
43 , bytestring >= 0.9.1.4
44− , conduit >= 1.0.11 && < 1.1
44+ , conduit >= 1.0.11 && < 1.2
45− , resourcet >= 0.3 && < 0.5
45+ , resourcet >= 0.3 && < 1.2
46 , aeson >= 0.5
46 , aeson >= 0.5
47 , containers
47 , containers
48 , unordered-containers
48 , unordered-containers