Skip to content
Open
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
11 changes: 10 additions & 1 deletion Network/CGI/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# OPTIONS_GHC -fglasgow-exts #-}
{-# LANGUAGE CPP, DeriveDataTypeable #-}
-----------------------------------------------------------------------------
-- |
-- Module : Network.CGI.Monad
Expand Down Expand Up @@ -40,8 +41,12 @@ 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
#else
import Data.Typeable (Typeable(..), Typeable1(..),
mkTyConApp, mkTyCon)
mkTyConApp, mkTyCon)
#endif

import Network.CGI.Protocol

Expand All @@ -55,10 +60,14 @@ 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
13 changes: 12 additions & 1 deletion Network/CGI/Protocol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- An implementation of the program side of the CGI protocol.
--
-----------------------------------------------------------------------------

{-# LANGUAGE CPP, DeriveDataTypeable #-}
module Network.CGI.Protocol (
-- * CGI request
CGIRequest(..), Input(..),
Expand Down Expand Up @@ -44,7 +44,12 @@ 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
#else
import Data.Typeable (Typeable(..), mkTyConApp, mkTyCon)
#endif


import Network.CGI.Header
import Network.CGI.Multipart
Expand Down Expand Up @@ -72,8 +77,10 @@ data CGIRequest =
}
deriving (Show)

#if ! MIN_VERSION_base(4,7,0)
instance Typeable CGIResult where
typeOf _ = mkTyConApp (mkTyCon "Network.CGI.Protocol.CGIResult") []
#endif

-- | The value of an input parameter, and some metadata.
data Input = Input {
Expand All @@ -90,7 +97,11 @@ data Input = Input {
-- | The result of a CGI program.
data CGIResult = CGIOutput ByteString
| CGINothing
#if MIN_VERSION_base(4,7,0)
deriving (Show, Read, Eq, Ord, Typeable)
#else
deriving (Show, Read, Eq, Ord)
#endif

--
-- * Running CGI actions
Expand Down