Browse Source

add Show instance to Annotation and add getAnnotation

master
Philipp Balzarek 12 years ago
parent
commit
9bb7c0933d
  1. 9
      source/Network/Xmpp/Concurrent/Types.hs

9
source/Network/Xmpp/Concurrent/Types.hs

@ -26,10 +26,17 @@ type StanzaHandler = (Stanza -> IO Bool) -- ^ outgoing stanza @@ -26,10 +26,17 @@ type StanzaHandler = (Stanza -> IO Bool) -- ^ outgoing stanza
-> IO [(Stanza, [Annotation])] -- ^ modified stanzas and
-- /additional/ annotations
data Annotation = forall f. (Typeable f, Show f) => Annotation f
data Annotation = forall f.(Typeable f, Show f) => Annotation{fromAnnotation :: f}
instance Show Annotation where
show (Annotation x) = "Annotation{ fromAnnotation = " ++ show x ++ "}"
type Annotated a = (a, [Annotation])
-- | Retrieve the first matching annotation
getAnnotation :: Typeable b => Annotated a -> Maybe b
getAnnotation = foldr (\(Annotation a) b -> maybe b Just $ cast a) Nothing . snd
data Plugin' = Plugin' { inHandler :: Stanza
-> [Annotation]
-> IO [(Stanza, [Annotation])]

Loading…
Cancel
Save