conduit 1.1

This commit is contained in:
Michael Snoyman 2014-03-27 16:38:52 +02:00
parent 3f1fe6e1c0
commit d764464152
19 changed files with 91 additions and 43 deletions

View File

@ -1,5 +1,5 @@
name: yesod-auth name: yesod-auth
version: 1.3.0.1 version: 1.3.0.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin author: Michael Snoyman, Patrick Brisbin
@ -31,9 +31,10 @@ library
, text >= 0.7 , text >= 0.7
, mime-mail >= 0.3 , mime-mail >= 0.3
, yesod-persistent >= 1.2 , yesod-persistent >= 1.2
, hamlet >= 1.1 && < 1.2 , hamlet >= 1.1
, shakespeare-css >= 1.0 && < 1.1 , shakespeare
, shakespeare-js >= 1.0.2 && < 1.3 , shakespeare-css >= 1.0
, shakespeare-js >= 1.0.2
, containers , containers
, unordered-containers , unordered-containers
, yesod-form >= 1.3 && < 1.4 , yesod-form >= 1.3 && < 1.4

View File

@ -64,8 +64,7 @@ import GhcBuild (buildPackage,
getBuildFlags, getPackageArgs) getBuildFlags, getPackageArgs)
import qualified Config as GHC import qualified Config as GHC
import Data.Conduit.Network (HostPreference (HostIPv4), import Data.Streaming.Network (bindPortTCP)
bindPort)
import Network (withSocketsDo) import Network (withSocketsDo)
#if MIN_VERSION_http_conduit(2, 0, 0) #if MIN_VERSION_http_conduit(2, 0, 0)
import Network.HTTP.Conduit (conduitManagerSettings, newManager) import Network.HTTP.Conduit (conduitManagerSettings, newManager)
@ -171,7 +170,7 @@ reverseProxy opts iappPort = do
checkPort :: Int -> IO Bool checkPort :: Int -> IO Bool
checkPort p = do checkPort p = do
es <- Ex.try $ bindPort p HostIPv4 es <- Ex.try $ bindPortTCP p "*4"
case es of case es of
Left (_ :: Ex.IOException) -> return False Left (_ :: Ex.IOException) -> return False
Right s -> do Right s -> do

View File

@ -2,7 +2,8 @@
module HsFile (mkHsFile) where module HsFile (mkHsFile) where
import Text.ProjectTemplate (createTemplate) import Text.ProjectTemplate (createTemplate)
import Data.Conduit import Data.Conduit
( ($$), (=$), runResourceT, ResourceT, ConduitM, awaitForever, yield, Source ) ( ($$), (=$), ConduitM, awaitForever, yield, Source )
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import qualified Data.Conduit.List as CL import qualified Data.Conduit.List as CL
import Prelude hiding (FilePath) import Prelude hiding (FilePath)
import Filesystem.Path ( FilePath ) import Filesystem.Path ( FilePath )

View File

@ -4,7 +4,8 @@ module Scaffolding.Scaffolder (scaffold) where
import Control.Arrow ((&&&)) import Control.Arrow ((&&&))
import qualified Data.ByteString.Char8 as S import qualified Data.ByteString.Char8 as S
import Data.Conduit (runResourceT, yield, ($$), ($$+-)) import Data.Conduit (yield, ($$), ($$+-))
import Control.Monad.Trans.Resource (runResourceT)
import Data.FileEmbed (embedFile) import Data.FileEmbed (embedFile)
import Data.String (fromString) import Data.String (fromString)
import qualified Data.Text as T import qualified Data.Text as T

View File

@ -1,5 +1,5 @@
name: yesod-bin name: yesod-bin
version: 1.2.7.3 version: 1.2.7.4
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -51,10 +51,11 @@ executable yesod
, ghc-paths >= 0.1 , ghc-paths >= 0.1
, parsec >= 2.1 && < 4 , parsec >= 2.1 && < 4
, text >= 0.11 , text >= 0.11
, shakespeare-text >= 1.0 && < 1.1 , shakespeare
, shakespeare >= 1.0.2 && < 1.3 , shakespeare-text >= 1.0
, shakespeare-js >= 1.0.2 && < 1.3 , shakespeare >= 1.0.2 && < 2.1
, shakespeare-css >= 1.0.2 && < 1.1 , shakespeare-js >= 1.0.2
, shakespeare-css >= 1.0.2
, bytestring >= 0.9.1.4 , bytestring >= 0.9.1.4
, time >= 1.1.4 , time >= 1.1.4
, template-haskell , template-haskell
@ -77,8 +78,9 @@ executable yesod
, fsnotify >= 0.0 && < 0.1 , fsnotify >= 0.0 && < 0.1
, split >= 0.2 && < 0.3 , split >= 0.2 && < 0.3
, file-embed , file-embed
, conduit >= 0.5 && < 1.1 , conduit >= 0.5 && < 1.2
, resourcet >= 0.3 && < 0.5 , conduit-extra
, resourcet >= 0.3 && < 1.2
, base64-bytestring , base64-bytestring
, lifted-base , lifted-base
, http-reverse-proxy >= 0.1.1 , http-reverse-proxy >= 0.1.1
@ -90,6 +92,7 @@ executable yesod
, warp >= 1.3.7.5 , warp >= 1.3.7.5
, wai >= 1.4 , wai >= 1.4
, data-default-class , data-default-class
, streaming-commons
ghc-options: -Wall -threaded ghc-options: -Wall -threaded
main-is: main.hs main-is: main.hs

View File

@ -61,7 +61,9 @@ GOX(Monoid w, RWST r w s)
GOX(Monoid w, Strict.RWST r w s) GOX(Monoid w, Strict.RWST r w s)
GO(Strict.StateT s) GO(Strict.StateT s)
GOX(Monoid w, Strict.WriterT w) GOX(Monoid w, Strict.WriterT w)
#if !MIN_VERSION_resourcet(1,1,0)
GO(ExceptionT) GO(ExceptionT)
#endif
GO(Pipe l i o u) GO(Pipe l i o u)
GO(ConduitM i o) GO(ConduitM i o)
#undef GO #undef GO
@ -85,7 +87,9 @@ GOX(Monoid w, RWST r w s)
GOX(Monoid w, Strict.RWST r w s) GOX(Monoid w, Strict.RWST r w s)
GO(Strict.StateT s) GO(Strict.StateT s)
GOX(Monoid w, Strict.WriterT w) GOX(Monoid w, Strict.WriterT w)
#if !MIN_VERSION_resourcet(1,1,0)
GO(ExceptionT) GO(ExceptionT)
#endif
GO(Pipe l i o u) GO(Pipe l i o u)
GO(ConduitM i o) GO(ConduitM i o)
#undef GO #undef GO

View File

@ -60,7 +60,8 @@ import Data.Monoid (mempty)
import Text.Hamlet (Html) import Text.Hamlet (Html)
import Text.Blaze.Html.Renderer.Utf8 (renderHtmlBuilder) import Text.Blaze.Html.Renderer.Utf8 (renderHtmlBuilder)
import Data.Conduit (Source, ResourceT, Flush (Chunk), ResumableSource, mapOutput) import Data.Conduit (Source, Flush (Chunk), ResumableSource, mapOutput)
import Control.Monad.Trans.Resource (ResourceT)
import Data.Conduit.Internal (ResumableSource (ResumableSource)) import Data.Conduit.Internal (ResumableSource (ResumableSource))
import qualified Data.Aeson as J import qualified Data.Aeson as J

View File

@ -40,6 +40,7 @@ import Data.Conduit.List (sourceList)
import Data.Conduit.Binary (sourceFile, sinkFile) import Data.Conduit.Binary (sourceFile, sinkFile)
import Data.Word (Word64) import Data.Word (Word64)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource (runResourceT, ResourceT)
import Control.Exception (throwIO) import Control.Exception (throwIO)
import Yesod.Core.Types import Yesod.Core.Types
import qualified Data.Map as Map import qualified Data.Map as Map

View File

@ -1,4 +1,5 @@
{-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-} {-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
module Yesod.Core.Json module Yesod.Core.Json
( -- * Convert from a JSON value ( -- * Convert from a JSON value
@ -28,6 +29,7 @@ module Yesod.Core.Json
import Yesod.Core.Handler (HandlerT, getRequest, invalidArgs, redirect, selectRep, provideRep, rawRequestBody, ProvidedRep) import Yesod.Core.Handler (HandlerT, getRequest, invalidArgs, redirect, selectRep, provideRep, rawRequestBody, ProvidedRep)
import Control.Monad.Trans.Writer (Writer) import Control.Monad.Trans.Writer (Writer)
import Control.Monad.Trans.Resource (runExceptionT)
import Data.Monoid (Endo) import Data.Monoid (Endo)
import Yesod.Core.Content (TypedContent) import Yesod.Core.Content (TypedContent)
import Yesod.Core.Types (reqAccept) import Yesod.Core.Types (reqAccept)
@ -42,6 +44,7 @@ import Data.Conduit.Attoparsec (sinkParser)
import Data.Text (pack) import Data.Text (pack)
import qualified Data.Vector as V import qualified Data.Vector as V
import Data.Conduit import Data.Conduit
import Data.Conduit.Lift
import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Char8 as B8
import Data.Maybe (listToMaybe) import Data.Maybe (listToMaybe)
import Control.Monad (liftM) import Control.Monad (liftM)
@ -92,7 +95,11 @@ provideJson = provideRep . return . J.toJSON
-- /Since: 0.3.0/ -- /Since: 0.3.0/
parseJsonBody :: (MonadHandler m, J.FromJSON a) => m (J.Result a) parseJsonBody :: (MonadHandler m, J.FromJSON a) => m (J.Result a)
parseJsonBody = do parseJsonBody = do
#if MIN_VERSION_resourcet(1,1,0)
eValue <- rawRequestBody $$ runCatchC (sinkParser JP.value')
#else
eValue <- runExceptionT $ rawRequestBody $$ sinkParser JP.value' eValue <- runExceptionT $ rawRequestBody $$ sinkParser JP.value'
#endif
return $ case eValue of return $ case eValue of
Left e -> J.Error $ show e Left e -> J.Error $ show e
Right value -> J.fromJSON value Right value -> J.fromJSON value

View File

@ -20,12 +20,13 @@ import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.Logger (LogLevel, LogSource, import Control.Monad.Logger (LogLevel, LogSource,
MonadLogger (..)) MonadLogger (..))
import Control.Monad.Trans.Control (MonadBaseControl (..)) import Control.Monad.Trans.Control (MonadBaseControl (..))
import Control.Monad.Trans.Resource (MonadResource (..), InternalState, runInternalState) import Control.Monad.Trans.Resource (MonadResource (..), InternalState, runInternalState, MonadThrow (..), monadThrow, ResourceT)
#if !MIN_VERSION_resourcet(1,1,0)
import Control.Monad.Trans.Resource (MonadUnsafeIO (..))
#endif
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy as L
import Data.Conduit (Flush, MonadThrow (..), import Data.Conduit (Flush, Source)
MonadUnsafeIO (..),
ResourceT, Source)
import Data.Dynamic (Dynamic) import Data.Dynamic (Dynamic)
import Data.IORef (IORef) import Data.IORef (IORef)
import Data.Map (Map, unionWith) import Data.Map (Map, unionWith)
@ -394,8 +395,17 @@ instance MonadBaseControl b m => MonadBaseControl b (WidgetT site m) where
instance MonadTrans (WidgetT site) where instance MonadTrans (WidgetT site) where
lift = WidgetT . const . liftM (, mempty) lift = WidgetT . const . liftM (, mempty)
instance MonadThrow m => MonadThrow (WidgetT site m) where instance MonadThrow m => MonadThrow (WidgetT site m) where
#if MIN_VERSION_resourcet(1,1,0)
throwM = lift . throwM
#else
monadThrow = lift . monadThrow monadThrow = lift . monadThrow
#endif
#if MIN_VERSION_resourcet(1,1,0)
instance (Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (WidgetT site m) where
#else
instance (Applicative m, MonadIO m, MonadUnsafeIO m, MonadThrow m) => MonadResource (WidgetT site m) where instance (Applicative m, MonadIO m, MonadUnsafeIO m, MonadThrow m) => MonadResource (WidgetT site m) where
#endif
liftResourceT f = WidgetT $ \hd -> liftIO $ fmap (, mempty) $ runInternalState f (handlerResource hd) liftResourceT f = WidgetT $ \hd -> liftIO $ fmap (, mempty) $ runInternalState f (handlerResource hd)
instance MonadIO m => MonadLogger (WidgetT site m) where instance MonadIO m => MonadLogger (WidgetT site m) where
@ -434,8 +444,17 @@ instance MonadBaseControl b m => MonadBaseControl b (HandlerT site m) where
restoreM (StH base) = HandlerT $ const $ restoreM base restoreM (StH base) = HandlerT $ const $ restoreM base
instance MonadThrow m => MonadThrow (HandlerT site m) where instance MonadThrow m => MonadThrow (HandlerT site m) where
#if MIN_VERSION_resourcet(1,1,0)
throwM = lift . monadThrow
#else
monadThrow = lift . monadThrow monadThrow = lift . monadThrow
#endif
#if MIN_VERSION_resourcet(1,1,0)
instance (MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (HandlerT site m) where
#else
instance (MonadIO m, MonadUnsafeIO m, MonadThrow m) => MonadResource (HandlerT site m) where instance (MonadIO m, MonadUnsafeIO m, MonadThrow m) => MonadResource (HandlerT site m) where
#endif
liftResourceT f = HandlerT $ \hd -> liftIO $ runInternalState f (handlerResource hd) liftResourceT f = HandlerT $ \hd -> liftIO $ runInternalState f (handlerResource hd)
instance MonadIO m => MonadLogger (HandlerT site m) where instance MonadIO m => MonadLogger (HandlerT site m) where

View File

@ -19,6 +19,7 @@ import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (withAsync) import Control.Concurrent.Async (withAsync)
import Control.Monad.Trans.Resource (register) import Control.Monad.Trans.Resource (register)
import Data.IORef import Data.IORef
import Data.Streaming.Network (bindPortTCP)
data App = App data App = App
@ -42,7 +43,7 @@ getFreePort = do
loop 43124 loop 43124
where where
loop port = do loop port = do
esocket <- try $ bindPort port "*" esocket <- try $ bindPortTCP port "*"
case esocket of case esocket of
Left (_ :: IOException) -> loop (succ port) Left (_ :: IOException) -> loop (succ port)
Right socket -> do Right socket -> do

View File

@ -1,5 +1,5 @@
name: yesod-core name: yesod-core
version: 1.2.9.1 version: 1.2.9.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -32,11 +32,11 @@ library
, text >= 0.7 , text >= 0.7
, template-haskell , template-haskell
, path-pieces >= 0.1.2 && < 0.2 , path-pieces >= 0.1.2 && < 0.2
, hamlet >= 1.1 && < 1.2 , hamlet >= 1.1
, shakespeare >= 1.0 && < 1.3 , shakespeare >= 1.0 && < 2.1
, shakespeare-js >= 1.0.2 && < 1.3 , shakespeare-js >= 1.0.2
, shakespeare-css >= 1.0 && < 1.1 , shakespeare-css >= 1.0
, shakespeare-i18n >= 1.0 && < 1.1 , shakespeare-i18n >= 1.0
, blaze-builder >= 0.2.1.4 && < 0.4 , blaze-builder >= 0.2.1.4 && < 0.4
, transformers >= 0.2.2 && < 0.4 , transformers >= 0.2.2 && < 0.4
, clientsession >= 0.9 && < 0.10 , clientsession >= 0.9 && < 0.10
@ -57,7 +57,7 @@ library
, wai-logger >= 0.2 , wai-logger >= 0.2
, monad-logger >= 0.3.1 && < 0.4 , monad-logger >= 0.3.1 && < 0.4
, conduit >= 0.5 , conduit >= 0.5
, resourcet >= 0.4.9 && < 0.5 , resourcet >= 0.4.9 && < 1.2
, lifted-base >= 0.1.2 , lifted-base >= 0.1.2
, attoparsec-conduit , attoparsec-conduit
, blaze-html >= 0.5 , blaze-html >= 0.5
@ -66,6 +66,7 @@ library
, safe , safe
, warp >= 1.3.8 , warp >= 1.3.8
, unix-compat , unix-compat
, conduit-extra
exposed-modules: Yesod.Core exposed-modules: Yesod.Core
Yesod.Core.Content Yesod.Core.Content
@ -124,6 +125,9 @@ test-suite tests
, network-conduit , network-conduit
, network , network
, async , async
, conduit-extra
, shakespeare
, streaming-commons
ghc-options: -Wall ghc-options: -Wall
extensions: TemplateHaskell extensions: TemplateHaskell

View File

@ -1,5 +1,5 @@
name: yesod-eventsource name: yesod-eventsource
version: 1.1.0.1 version: 1.1.0.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Felipe Lessa <felipe.lessa@gmail.com> author: Felipe Lessa <felipe.lessa@gmail.com>
@ -29,7 +29,7 @@ description:
library library
build-depends: base >= 4 && < 5 build-depends: base >= 4 && < 5
, yesod-core == 1.2.* , yesod-core == 1.2.*
, conduit >= 0.5 && < 1.1 , conduit >= 0.5 && < 1.2
, wai >= 1.3 , wai >= 1.3
, wai-eventsource >= 1.3 , wai-eventsource >= 1.3
, blaze-builder , blaze-builder

View File

@ -1,5 +1,5 @@
name: yesod-form name: yesod-form
version: 1.3.8 version: 1.3.8.1
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -17,9 +17,10 @@ library
, yesod-core >= 1.2 && < 1.3 , yesod-core >= 1.2 && < 1.3
, yesod-persistent >= 1.2 && < 1.3 , yesod-persistent >= 1.2 && < 1.3
, time >= 1.1.4 , time >= 1.1.4
, hamlet >= 1.1 && < 1.2 , hamlet >= 1.1
, shakespeare-css >= 1.0 && < 1.1 , shakespeare
, shakespeare-js >= 1.0.2 && < 1.3 , shakespeare-css >= 1.0
, shakespeare-js >= 1.0.2
, persistent >= 1.2 && < 1.4 , persistent >= 1.2 && < 1.4
, template-haskell , template-haskell
, transformers >= 0.2.2 , transformers >= 0.2.2

View File

@ -1,5 +1,5 @@
name: yesod-newsfeed name: yesod-newsfeed
version: 1.2.0.1 version: 1.2.0.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin author: Michael Snoyman, Patrick Brisbin
@ -16,7 +16,8 @@ library
build-depends: base >= 4 && < 5 build-depends: base >= 4 && < 5
, yesod-core >= 1.2 && < 1.3 , yesod-core >= 1.2 && < 1.3
, time >= 1.1.4 , time >= 1.1.4
, hamlet >= 1.1 && < 1.2 , hamlet >= 1.1
, shakespeare
, bytestring >= 0.9.1.4 , bytestring >= 0.9.1.4
, text >= 0.9 , text >= 0.9
, xml-conduit >= 1.0 , xml-conduit >= 1.0

View File

@ -66,6 +66,7 @@ import System.Directory
import Control.Monad import Control.Monad
import Data.FileEmbed (embedDir) import Data.FileEmbed (embedDir)
import Control.Monad.Trans.Resource (runResourceT)
import Yesod.Core import Yesod.Core
import Yesod.Core.Types import Yesod.Core.Types

View File

@ -41,6 +41,7 @@ library
, http-types >= 0.7 , http-types >= 0.7
, unix-compat >= 0.2 , unix-compat >= 0.2
, conduit >= 0.5 , conduit >= 0.5
, conduit-extra
, cryptohash-conduit >= 0.1 , cryptohash-conduit >= 0.1
, cryptohash >= 0.11 , cryptohash >= 0.11
, system-filepath >= 0.4.6 && < 0.5 , system-filepath >= 0.4.6 && < 0.5
@ -101,12 +102,12 @@ test-suite tests
, shakespeare-css , shakespeare-css
, mime-types , mime-types
, hjsmin , hjsmin
, process-conduit
, filepath , filepath
, resourcet , resourcet
, unordered-containers , unordered-containers
, async , async
, process , process
, conduit-extra
ghc-options: -Wall -threaded ghc-options: -Wall -threaded
extensions: TemplateHaskell extensions: TemplateHaskell

View File

@ -1,5 +1,5 @@
name: yesod-test name: yesod-test
version: 1.2.1.1 version: 1.2.1.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar> author: Nubis <nubis@woobiz.com.ar>

View File

@ -1,5 +1,5 @@
name: yesod name: yesod
version: 1.2.5.1 version: 1.2.5.2
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -30,9 +30,9 @@ library
, transformers >= 0.2.2 && < 0.4 , transformers >= 0.2.2 && < 0.4
, wai >= 1.3 , wai >= 1.3
, wai-extra >= 1.3 , wai-extra >= 1.3
, hamlet >= 1.1 && < 1.2 , hamlet >= 1.1
, shakespeare-js >= 1.0.2 && < 1.3 , shakespeare-js >= 1.0.2
, shakespeare-css >= 1.0 && < 1.1 , shakespeare-css >= 1.0
, warp >= 1.3 , warp >= 1.3
, blaze-html >= 0.5 , blaze-html >= 0.5
, blaze-markup >= 0.5.1 , blaze-markup >= 0.5.1
@ -48,6 +48,8 @@ library
, bytestring , bytestring
, monad-logger , monad-logger
, fast-logger , fast-logger
, conduit-extra
, shakespeare
exposed-modules: Yesod exposed-modules: Yesod
, Yesod.Default.Config , Yesod.Default.Config