Skip to content

Commit

Permalink
conduit 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Mar 27, 2014
1 parent 3f1fe6e commit d764464
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 43 deletions.
9 changes: 5 additions & 4 deletions yesod-auth/yesod-auth.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-auth
version: 1.3.0.1
version: 1.3.0.2
license: MIT
license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin
Expand Down Expand Up @@ -31,9 +31,10 @@ library
, text >= 0.7
, mime-mail >= 0.3
, yesod-persistent >= 1.2
, hamlet >= 1.1 && < 1.2
, shakespeare-css >= 1.0 && < 1.1
, shakespeare-js >= 1.0.2 && < 1.3
, hamlet >= 1.1
, shakespeare
, shakespeare-css >= 1.0
, shakespeare-js >= 1.0.2
, containers
, unordered-containers
, yesod-form >= 1.3 && < 1.4
Expand Down
5 changes: 2 additions & 3 deletions yesod-bin/Devel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ import GhcBuild (buildPackage,
getBuildFlags, getPackageArgs)

import qualified Config as GHC
import Data.Conduit.Network (HostPreference (HostIPv4),
bindPort)
import Data.Streaming.Network (bindPortTCP)
import Network (withSocketsDo)
#if MIN_VERSION_http_conduit(2, 0, 0)
import Network.HTTP.Conduit (conduitManagerSettings, newManager)
Expand Down Expand Up @@ -171,7 +170,7 @@ reverseProxy opts iappPort = do

checkPort :: Int -> IO Bool
checkPort p = do
es <- Ex.try $ bindPort p HostIPv4
es <- Ex.try $ bindPortTCP p "*4"
case es of
Left (_ :: Ex.IOException) -> return False
Right s -> do
Expand Down
3 changes: 2 additions & 1 deletion yesod-bin/HsFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
module HsFile (mkHsFile) where
import Text.ProjectTemplate (createTemplate)
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 Prelude hiding (FilePath)
import Filesystem.Path ( FilePath )
Expand Down
3 changes: 2 additions & 1 deletion yesod-bin/Scaffolding/Scaffolder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module Scaffolding.Scaffolder (scaffold) where

import Control.Arrow ((&&&))
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.String (fromString)
import qualified Data.Text as T
Expand Down
17 changes: 10 additions & 7 deletions yesod-bin/yesod-bin.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-bin
version: 1.2.7.3
version: 1.2.7.4
license: MIT
license-file: LICENSE
author: Michael Snoyman <[email protected]>
Expand Down Expand Up @@ -51,10 +51,11 @@ executable yesod
, ghc-paths >= 0.1
, parsec >= 2.1 && < 4
, text >= 0.11
, shakespeare-text >= 1.0 && < 1.1
, shakespeare >= 1.0.2 && < 1.3
, shakespeare-js >= 1.0.2 && < 1.3
, shakespeare-css >= 1.0.2 && < 1.1
, shakespeare
, shakespeare-text >= 1.0
, shakespeare >= 1.0.2 && < 2.1
, shakespeare-js >= 1.0.2
, shakespeare-css >= 1.0.2
, bytestring >= 0.9.1.4
, time >= 1.1.4
, template-haskell
Expand All @@ -77,8 +78,9 @@ executable yesod
, fsnotify >= 0.0 && < 0.1
, split >= 0.2 && < 0.3
, file-embed
, conduit >= 0.5 && < 1.1
, resourcet >= 0.3 && < 0.5
, conduit >= 0.5 && < 1.2
, conduit-extra
, resourcet >= 0.3 && < 1.2
, base64-bytestring
, lifted-base
, http-reverse-proxy >= 0.1.1
Expand All @@ -90,6 +92,7 @@ executable yesod
, warp >= 1.3.7.5
, wai >= 1.4
, data-default-class
, streaming-commons

ghc-options: -Wall -threaded
main-is: main.hs
Expand Down
4 changes: 4 additions & 0 deletions yesod-core/Yesod/Core/Class/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ GOX(Monoid w, RWST r w s)
GOX(Monoid w, Strict.RWST r w s)
GO(Strict.StateT s)
GOX(Monoid w, Strict.WriterT w)
#if !MIN_VERSION_resourcet(1,1,0)
GO(ExceptionT)
#endif
GO(Pipe l i o u)
GO(ConduitM i o)
#undef GO
Expand All @@ -85,7 +87,9 @@ GOX(Monoid w, RWST r w s)
GOX(Monoid w, Strict.RWST r w s)
GO(Strict.StateT s)
GOX(Monoid w, Strict.WriterT w)
#if !MIN_VERSION_resourcet(1,1,0)
GO(ExceptionT)
#endif
GO(Pipe l i o u)
GO(ConduitM i o)
#undef GO
Expand Down
3 changes: 2 additions & 1 deletion yesod-core/Yesod/Core/Content.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ import Data.Monoid (mempty)

import Text.Hamlet (Html)
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 qualified Data.Aeson as J
Expand Down
1 change: 1 addition & 0 deletions yesod-core/Yesod/Core/Internal/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Data.Conduit.List (sourceList)
import Data.Conduit.Binary (sourceFile, sinkFile)
import Data.Word (Word64)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource (runResourceT, ResourceT)
import Control.Exception (throwIO)
import Yesod.Core.Types
import qualified Data.Map as Map
Expand Down
7 changes: 7 additions & 0 deletions yesod-core/Yesod/Core/Json.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Yesod.Core.Json
( -- * Convert from a JSON value
Expand Down Expand Up @@ -28,6 +29,7 @@ module Yesod.Core.Json

import Yesod.Core.Handler (HandlerT, getRequest, invalidArgs, redirect, selectRep, provideRep, rawRequestBody, ProvidedRep)
import Control.Monad.Trans.Writer (Writer)
import Control.Monad.Trans.Resource (runExceptionT)
import Data.Monoid (Endo)
import Yesod.Core.Content (TypedContent)
import Yesod.Core.Types (reqAccept)
Expand All @@ -42,6 +44,7 @@ import Data.Conduit.Attoparsec (sinkParser)
import Data.Text (pack)
import qualified Data.Vector as V
import Data.Conduit
import Data.Conduit.Lift
import qualified Data.ByteString.Char8 as B8
import Data.Maybe (listToMaybe)
import Control.Monad (liftM)
Expand Down Expand Up @@ -92,7 +95,11 @@ provideJson = provideRep . return . J.toJSON
-- /Since: 0.3.0/
parseJsonBody :: (MonadHandler m, J.FromJSON a) => m (J.Result a)
parseJsonBody = do
#if MIN_VERSION_resourcet(1,1,0)
eValue <- rawRequestBody $$ runCatchC (sinkParser JP.value')
#else
eValue <- runExceptionT $ rawRequestBody $$ sinkParser JP.value'
#endif
return $ case eValue of
Left e -> J.Error $ show e
Right value -> J.fromJSON value
Expand Down
27 changes: 23 additions & 4 deletions yesod-core/Yesod/Core/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.Logger (LogLevel, LogSource,
MonadLogger (..))
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 qualified Data.ByteString.Lazy as L
import Data.Conduit (Flush, MonadThrow (..),
MonadUnsafeIO (..),
ResourceT, Source)
import Data.Conduit (Flush, Source)
import Data.Dynamic (Dynamic)
import Data.IORef (IORef)
import Data.Map (Map, unionWith)
Expand Down Expand Up @@ -394,8 +395,17 @@ instance MonadBaseControl b m => MonadBaseControl b (WidgetT site m) where
instance MonadTrans (WidgetT site) where
lift = WidgetT . const . liftM (, mempty)
instance MonadThrow m => MonadThrow (WidgetT site m) where
#if MIN_VERSION_resourcet(1,1,0)
throwM = lift . throwM
#else
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
#endif
liftResourceT f = WidgetT $ \hd -> liftIO $ fmap (, mempty) $ runInternalState f (handlerResource hd)

instance MonadIO m => MonadLogger (WidgetT site m) where
Expand Down Expand Up @@ -434,8 +444,17 @@ instance MonadBaseControl b m => MonadBaseControl b (HandlerT site m) where
restoreM (StH base) = HandlerT $ const $ restoreM base

instance MonadThrow m => MonadThrow (HandlerT site m) where
#if MIN_VERSION_resourcet(1,1,0)
throwM = lift . monadThrow
#else
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
#endif
liftResourceT f = HandlerT $ \hd -> liftIO $ runInternalState f (handlerResource hd)

instance MonadIO m => MonadLogger (HandlerT site m) where
Expand Down
3 changes: 2 additions & 1 deletion yesod-core/test/YesodCoreTest/RawResponse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (withAsync)
import Control.Monad.Trans.Resource (register)
import Data.IORef
import Data.Streaming.Network (bindPortTCP)

data App = App

Expand All @@ -42,7 +43,7 @@ getFreePort = do
loop 43124
where
loop port = do
esocket <- try $ bindPort port "*"
esocket <- try $ bindPortTCP port "*"
case esocket of
Left (_ :: IOException) -> loop (succ port)
Right socket -> do
Expand Down
18 changes: 11 additions & 7 deletions yesod-core/yesod-core.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-core
version: 1.2.9.1
version: 1.2.9.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <[email protected]>
Expand Down Expand Up @@ -32,11 +32,11 @@ library
, text >= 0.7
, template-haskell
, path-pieces >= 0.1.2 && < 0.2
, hamlet >= 1.1 && < 1.2
, shakespeare >= 1.0 && < 1.3
, shakespeare-js >= 1.0.2 && < 1.3
, shakespeare-css >= 1.0 && < 1.1
, shakespeare-i18n >= 1.0 && < 1.1
, hamlet >= 1.1
, shakespeare >= 1.0 && < 2.1
, shakespeare-js >= 1.0.2
, shakespeare-css >= 1.0
, shakespeare-i18n >= 1.0
, blaze-builder >= 0.2.1.4 && < 0.4
, transformers >= 0.2.2 && < 0.4
, clientsession >= 0.9 && < 0.10
Expand All @@ -57,7 +57,7 @@ library
, wai-logger >= 0.2
, monad-logger >= 0.3.1 && < 0.4
, conduit >= 0.5
, resourcet >= 0.4.9 && < 0.5
, resourcet >= 0.4.9 && < 1.2
, lifted-base >= 0.1.2
, attoparsec-conduit
, blaze-html >= 0.5
Expand All @@ -66,6 +66,7 @@ library
, safe
, warp >= 1.3.8
, unix-compat
, conduit-extra

exposed-modules: Yesod.Core
Yesod.Core.Content
Expand Down Expand Up @@ -124,6 +125,9 @@ test-suite tests
, network-conduit
, network
, async
, conduit-extra
, shakespeare
, streaming-commons
ghc-options: -Wall
extensions: TemplateHaskell

Expand Down
4 changes: 2 additions & 2 deletions yesod-eventsource/yesod-eventsource.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-eventsource
version: 1.1.0.1
version: 1.1.0.2
license: MIT
license-file: LICENSE
author: Felipe Lessa <[email protected]>
Expand Down Expand Up @@ -29,7 +29,7 @@ description:
library
build-depends: base >= 4 && < 5
, yesod-core == 1.2.*
, conduit >= 0.5 && < 1.1
, conduit >= 0.5 && < 1.2
, wai >= 1.3
, wai-eventsource >= 1.3
, blaze-builder
Expand Down
9 changes: 5 additions & 4 deletions yesod-form/yesod-form.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-form
version: 1.3.8
version: 1.3.8.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <[email protected]>
Expand All @@ -17,9 +17,10 @@ library
, yesod-core >= 1.2 && < 1.3
, yesod-persistent >= 1.2 && < 1.3
, time >= 1.1.4
, hamlet >= 1.1 && < 1.2
, shakespeare-css >= 1.0 && < 1.1
, shakespeare-js >= 1.0.2 && < 1.3
, hamlet >= 1.1
, shakespeare
, shakespeare-css >= 1.0
, shakespeare-js >= 1.0.2
, persistent >= 1.2 && < 1.4
, template-haskell
, transformers >= 0.2.2
Expand Down
5 changes: 3 additions & 2 deletions yesod-newsfeed/yesod-newsfeed.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-newsfeed
version: 1.2.0.1
version: 1.2.0.2
license: MIT
license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin
Expand All @@ -16,7 +16,8 @@ library
build-depends: base >= 4 && < 5
, yesod-core >= 1.2 && < 1.3
, time >= 1.1.4
, hamlet >= 1.1 && < 1.2
, hamlet >= 1.1
, shakespeare
, bytestring >= 0.9.1.4
, text >= 0.9
, xml-conduit >= 1.0
Expand Down
1 change: 1 addition & 0 deletions yesod-static/Yesod/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import System.Directory
import Control.Monad
import Data.FileEmbed (embedDir)

import Control.Monad.Trans.Resource (runResourceT)
import Yesod.Core
import Yesod.Core.Types

Expand Down
3 changes: 2 additions & 1 deletion yesod-static/yesod-static.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ library
, http-types >= 0.7
, unix-compat >= 0.2
, conduit >= 0.5
, conduit-extra
, cryptohash-conduit >= 0.1
, cryptohash >= 0.11
, system-filepath >= 0.4.6 && < 0.5
Expand Down Expand Up @@ -101,12 +102,12 @@ test-suite tests
, shakespeare-css
, mime-types
, hjsmin
, process-conduit
, filepath
, resourcet
, unordered-containers
, async
, process
, conduit-extra

ghc-options: -Wall -threaded
extensions: TemplateHaskell
Expand Down
2 changes: 1 addition & 1 deletion yesod-test/yesod-test.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yesod-test
version: 1.2.1.1
version: 1.2.1.2
license: MIT
license-file: LICENSE
author: Nubis <[email protected]>
Expand Down
Loading

0 comments on commit d764464

Please sign in to comment.