diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index 84f7d23..86044ee 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -28,9 +28,11 @@ Extra-Source-Files: README.md Library hs-source-dirs: source Exposed: True + -- The only different between the below two blocks is that the first one caps - -- the range for the `bytestring' package. - If impl(ghc == 7.0.1) + -- the range for the `bytestring' package, and that the second one includes + -- `template-haskell' for GHC 7.6.1 and above. + If impl(ghc ==7.0.1) { Build-Depends: attoparsec >=0.10.0.3 , base >4 && <5 @@ -56,7 +58,6 @@ Library , split >=0.1.2.3 , stm >=2.1.2.1 , stringprep >=0.1.3 - , template-haskell >=2.5 , text >=0.11.1.5 , tls >=1.1.0 , tls-extra >=0.5.0 @@ -66,41 +67,79 @@ Library , xml-conduit >=1.0 , xml-picklers >=0.3.3 } - else + Else { - Build-Depends: attoparsec >=0.10.0.3 - , base >4 && <5 - , base64-bytestring >=0.1.0.0 - , binary >=0.4.1 - , bytestring >=0.9.1.9 - , conduit >=0.5 - , containers >=0.5.0.0 - , crypto-api >=0.9 - , crypto-random-api >=0.2 - , cryptohash >=0.6.1 - , cryptohash-cryptoapi >=0.1 - , data-default >=0.2 - , dns >=0.3.0 - , hslogger >=1.1.0 - , iproute >=1.2.4 - , lifted-base >=0.1.0.1 - , mtl >=2.0.0.0 - , network >=2.4.1.0 - , pureMD5 >=2.1.2.1 - , resourcet >=0.3.0 - , random >=1.0.0.0 - , split >=0.1.2.3 - , stm >=2.1.2.1 - , stringprep >=0.1.3 - , template-haskell >=2.5 - , text >=0.11.1.5 - , tls >=1.1.0 - , tls-extra >=0.5.0 - , transformers >=0.2.2.0 - , void >=0.5.5 - , xml-types >=0.3.1 - , xml-conduit >=1.0 - , xml-picklers >=0.3.3 + If impl(ghc >=7.6.1) + { + Build-Depends: attoparsec >=0.10.0.3 + , base >4 && <5 + , base64-bytestring >=0.1.0.0 + , binary >=0.4.1 + , bytestring >=0.9.1.9 + , conduit >=0.5 + , containers >=0.5.0.0 + , crypto-api >=0.9 + , crypto-random-api >=0.2 + , cryptohash >=0.6.1 + , cryptohash-cryptoapi >=0.1 + , data-default >=0.2 + , dns >=0.3.0 + , hslogger >=1.1.0 + , iproute >=1.2.4 + , lifted-base >=0.1.0.1 + , mtl >=2.0.0.0 + , network >=2.4.1.0 + , pureMD5 >=2.1.2.1 + , resourcet >=0.3.0 + , random >=1.0.0.0 + , split >=0.1.2.3 + , stm >=2.1.2.1 + , stringprep >=0.1.3 + , template-haskell >=2.5 + , text >=0.11.1.5 + , tls >=1.1.0 + , tls-extra >=0.5.0 + , transformers >=0.2.2.0 + , void >=0.5.5 + , xml-types >=0.3.1 + , xml-conduit >=1.0 + , xml-picklers >=0.3.3 + } + Else + { + Build-Depends: attoparsec >=0.10.0.3 + , base >4 && <5 + , base64-bytestring >=0.1.0.0 + , binary >=0.4.1 + , bytestring >=0.9.1.9 + , conduit >=0.5 + , containers >=0.5.0.0 + , crypto-api >=0.9 + , crypto-random-api >=0.2 + , cryptohash >=0.6.1 + , cryptohash-cryptoapi >=0.1 + , data-default >=0.2 + , dns >=0.3.0 + , hslogger >=1.1.0 + , iproute >=1.2.4 + , lifted-base >=0.1.0.1 + , mtl >=2.0.0.0 + , network >=2.4.1.0 + , pureMD5 >=2.1.2.1 + , resourcet >=0.3.0 + , random >=1.0.0.0 + , split >=0.1.2.3 + , stm >=2.1.2.1 + , stringprep >=0.1.3 + , text >=0.11.1.5 + , tls >=1.1.0 + , tls-extra >=0.5.0 + , transformers >=0.2.2.0 + , void >=0.5.5 + , xml-types >=0.3.1 + , xml-conduit >=1.0 + , xml-picklers >=0.3.3 + } } Exposed-modules: Network.Xmpp , Network.Xmpp.IM diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index 0ea3561..a08a972 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -21,7 +21,7 @@ -- For low-level access to Pontarius XMPP, see the "Network.Xmpp.Internal" -- module. -{-# LANGUAGE NoMonomorphismRestriction, OverloadedStrings #-} +{-# LANGUAGE CPP, NoMonomorphismRestriction, OverloadedStrings #-} module Network.Xmpp ( -- * Session management @@ -46,7 +46,9 @@ module Network.Xmpp -- for addressing entities in the network. It is somewhat similar to an e-mail -- address, but contains three parts instead of two. , Jid +#if __GLASGOW_HASKELL >= 706 , jidQ +#endif , isBare , isFull , jidFromText diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index 4ee22ce..28372e9 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -1,6 +1,11 @@ +{-# LANGUAGE CPP #-} + +#if __GLASGOW_HASKELL >= 706 +{-# LANGUAGE TemplateHaskell #-} +#endif + {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE TupleSections #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-} @@ -44,7 +49,9 @@ module Network.Xmpp.Types , StreamConfiguration(..) , langTag , Jid(..) +#if __GLASGOW_HASKELL >= 706 , jidQ +#endif , isBare , isFull , jidFromText @@ -78,8 +85,10 @@ import Data.Text (Text) import qualified Data.Text as Text import Data.Typeable(Typeable) import Data.XML.Types +#if __GLASGOW_HASKELL >= 706 import Language.Haskell.TH import Language.Haskell.TH.Quote +#endif import Network import Network.DNS import Network.TLS hiding (Version) @@ -962,6 +971,7 @@ instance Read Jid where [(parseJid (read s' :: String), r)] -- May fail with "Prelude.read: no parse" -- or the `parseJid' error message (see below) +#if __GLASGOW_HASKELL >= 706 jidQ :: QuasiQuoter jidQ = QuasiQuoter { quoteExp = \s -> do when (head s == ' ') . fail $ "Leading whitespaces in JID" ++ show s @@ -981,6 +991,7 @@ jidQ = QuasiQuoter { quoteExp = \s -> do textE t = [| Text.pack $(stringE $ Text.unpack t) |] mbTextE Nothing = [| Nothing |] mbTextE (Just s) = [| Just $(textE s) |] +#endif -- | Parses a JID string. --