Browse Source

add jid QuasiQuoter (synonym to jidQ)

master
Philipp Balzarek 12 years ago
parent
commit
a073417470
  1. 1
      source/Network/Xmpp.hs
  2. 8
      source/Network/Xmpp/Types.hs

1
source/Network/Xmpp.hs

@ -51,6 +51,7 @@ module Network.Xmpp
, Jid , Jid
#if WITH_TEMPLATE_HASKELL #if WITH_TEMPLATE_HASKELL
, jidQ , jidQ
, jid
#endif #endif
, isBare , isBare
, isFull , isFull

8
source/Network/Xmpp/Types.hs

@ -55,6 +55,7 @@ module Network.Xmpp.Types
, Jid(..) , Jid(..)
#if WITH_TEMPLATE_HASKELL #if WITH_TEMPLATE_HASKELL
, jidQ , jidQ
, jid
#endif #endif
, isBare , isBare
, isFull , isFull
@ -817,8 +818,8 @@ instance TH.Lift Jid where
-- @ -- @
-- [jidQ|localpart\@domainpart/resourcepart|] -- [jidQ|localpart\@domainpart/resourcepart|]
-- @ -- @
jidQ :: QuasiQuoter jid :: QuasiQuoter
jidQ = QuasiQuoter { quoteExp = \s -> do jid = QuasiQuoter { quoteExp = \s -> do
when (head s == ' ') . fail $ "Leading whitespaces in JID" ++ show s when (head s == ' ') . fail $ "Leading whitespaces in JID" ++ show s
let t = Text.pack s let t = Text.pack s
when (Text.last t == ' ') . reportWarning $ "Trailing whitespace in JID " ++ show s when (Text.last t == ' ') . reportWarning $ "Trailing whitespace in JID " ++ show s
@ -830,6 +831,9 @@ jidQ = QuasiQuoter { quoteExp = \s -> do
, quoteDec = fail "jid QQ can't be used in declaration context" , quoteDec = fail "jid QQ can't be used in declaration context"
} }
-- | synonym for 'jid'
jidQ :: QuasiQuoter
jidQ = jidQ
#endif #endif
-- Produces a LangTag value in the format "parseLangTag \"<jid>\"". -- Produces a LangTag value in the format "parseLangTag \"<jid>\"".

Loading…
Cancel
Save