Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to support base-4.7 from GHC 7.7-2013116 #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Network/CGI/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#if MIN_VERSION_base(4,7,0)
{-# LANGUAGE DeriveDataTypeable #-}
#endif

{-# OPTIONS_GHC -fglasgow-exts #-}
-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -40,8 +44,13 @@ import Control.Monad.Error (MonadError(..))
import Control.Monad.Reader (ReaderT(..), asks)
import Control.Monad.Writer (WriterT(..), tell)
import Control.Monad.Trans (MonadTrans, MonadIO, liftIO, lift)

#if MIN_VERSION_base(4,7,0)
import Data.Typeable (Typeable())
#else
import Data.Typeable (Typeable(..), Typeable1(..),
mkTyConApp, mkTyCon)
#endif

import Network.CGI.Protocol

Expand All @@ -55,10 +64,13 @@ type CGI a = CGIT IO a

-- | The CGIT monad transformer.
newtype CGIT m a = CGIT { unCGIT :: ReaderT CGIRequest (WriterT Headers m) a }

#if MIN_VERSION_base(4,7,0)
deriving (Typeable)
#else
instance (Typeable1 m, Typeable a) => Typeable (CGIT m a) where
typeOf _ = mkTyConApp (mkTyCon "Network.CGI.Monad.CGIT")
[typeOf1 (undefined :: m a), typeOf (undefined :: a)]
#endif

instance (Functor m, Monad m) => Functor (CGIT m) where
fmap f c = CGIT (fmap f (unCGIT c))
Expand Down Expand Up @@ -119,7 +131,7 @@ catchCGI = catch

-- | Catches any exception thrown by an CGI action, and returns either
-- the exception, or if no exception was raised, the result of the action.
tryCGI :: (MonadCGI m, MonadCatchIO m) => m a -> m (Either SomeException a)
tryCGI :: (MonadCGI m, MonadCatchIO m, Functor m) => m a -> m (Either SomeException a)
tryCGI = try

{-# DEPRECATED handleExceptionCGI "Use catchCGI instead." #-}
Expand Down
14 changes: 13 additions & 1 deletion Network/CGI/Protocol.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if MIN_VERSION_base(4,7,0)
{-# LANGUAGE DeriveDataTypeable #-}
#endif

-----------------------------------------------------------------------------
-- |
-- Module : Network.CGI.Protocol
Expand Down Expand Up @@ -44,7 +49,11 @@ import System.IO (Handle, hPutStrLn, stderr, hFlush, hSetBinaryMode)
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.ByteString.Lazy.Char8 (ByteString)

#if MIN_VERSION_base(4,7,0)
import Data.Typeable (Typeable())
#else
import Data.Typeable (Typeable(..), mkTyConApp, mkTyCon)
#endif

import Network.CGI.Header
import Network.CGI.Multipart
Expand All @@ -70,11 +79,14 @@ data CGIRequest =
-- "multipart\/form-data" format.
cgiRequestBody :: ByteString
}
#if MIN_VERSION_base(4,7,0)
deriving (Show, Typeable)
#else
deriving (Show)

instance Typeable CGIResult where
typeOf _ = mkTyConApp (mkTyCon "Network.CGI.Protocol.CGIResult") []

#endif
-- | The value of an input parameter, and some metadata.
data Input = Input {
inputValue :: ByteString,
Expand Down
2 changes: 1 addition & 1 deletion cgi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Library
network >= 2.0,
parsec >= 2.0,
mtl >= 1.0,
MonadCatchIO-mtl,
MonadCatchIO-transformers,
xhtml >= 3000.0.0
If flag(split-base)
Build-depends: base >= 3 && < 5, old-time, old-locale, containers
Expand Down