|
|
|
@ -1,5 +1,6 @@ |
|
|
|
{-# LANGUAGE DeriveDataTypeable #-} |
|
|
|
{-# LANGUAGE DeriveDataTypeable #-} |
|
|
|
{-# LANGUAGE TupleSections #-} |
|
|
|
{-# LANGUAGE TupleSections #-} |
|
|
|
|
|
|
|
{-# LANGUAGE TemplateHaskell #-} |
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-} |
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-} |
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-} |
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-} |
|
|
|
{-# LANGUAGE StandaloneDeriving #-} |
|
|
|
{-# LANGUAGE StandaloneDeriving #-} |
|
|
|
@ -43,6 +44,7 @@ module Network.Xmpp.Types |
|
|
|
, StreamConfiguration(..) |
|
|
|
, StreamConfiguration(..) |
|
|
|
, langTag |
|
|
|
, langTag |
|
|
|
, Jid(..) |
|
|
|
, Jid(..) |
|
|
|
|
|
|
|
, jidQ |
|
|
|
, isBare |
|
|
|
, isBare |
|
|
|
, isFull |
|
|
|
, isFull |
|
|
|
, jidFromText |
|
|
|
, jidFromText |
|
|
|
@ -76,6 +78,8 @@ import Data.Text (Text) |
|
|
|
import qualified Data.Text as Text |
|
|
|
import qualified Data.Text as Text |
|
|
|
import Data.Typeable(Typeable) |
|
|
|
import Data.Typeable(Typeable) |
|
|
|
import Data.XML.Types |
|
|
|
import Data.XML.Types |
|
|
|
|
|
|
|
import Language.Haskell.TH.Quote |
|
|
|
|
|
|
|
import Language.Haskell.TH |
|
|
|
import Network |
|
|
|
import Network |
|
|
|
import Network.DNS |
|
|
|
import Network.DNS |
|
|
|
import Network.TLS hiding (Version) |
|
|
|
import Network.TLS hiding (Version) |
|
|
|
@ -960,6 +964,22 @@ instance Read Jid where |
|
|
|
[(parseJid (read s' :: String), r)] -- May fail with "Prelude.read: no parse" |
|
|
|
[(parseJid (read s' :: String), r)] -- May fail with "Prelude.read: no parse" |
|
|
|
-- or the `parseJid' error message (see below) |
|
|
|
-- or the `parseJid' error message (see below) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jidQ :: QuasiQuoter |
|
|
|
|
|
|
|
jidQ = QuasiQuoter { quoteExp = \s -> case jidFromText (Text.pack s) of |
|
|
|
|
|
|
|
Nothing -> fail $ "Could not parse JID " ++ s |
|
|
|
|
|
|
|
Just j -> [| Jid $(mbTextE $ localpart_ j) |
|
|
|
|
|
|
|
$(textE $ domainpart_ j) |
|
|
|
|
|
|
|
$(mbTextE $ resourcepart_ j) |
|
|
|
|
|
|
|
|] |
|
|
|
|
|
|
|
, quotePat = fail "Jid patterns aren't implemented" |
|
|
|
|
|
|
|
, quoteType = fail "jid QQ can't be used in type context" |
|
|
|
|
|
|
|
, quoteDec = fail "jid QQ can't be used in declaration context" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
where |
|
|
|
|
|
|
|
textE t = [| Text.pack $(stringE $ Text.unpack t) |] |
|
|
|
|
|
|
|
mbTextE Nothing = [| Nothing |] |
|
|
|
|
|
|
|
mbTextE (Just s) = [| Just $(textE s) |] |
|
|
|
|
|
|
|
|
|
|
|
-- | Parses a JID string. |
|
|
|
-- | Parses a JID string. |
|
|
|
-- |
|
|
|
-- |
|
|
|
-- Note: This function is only meant to be used to reverse @Jid@ Show |
|
|
|
-- Note: This function is only meant to be used to reverse @Jid@ Show |
|
|
|
|