diff --git a/source/Network/Xmpp/Concurrent/Types.hs b/source/Network/Xmpp/Concurrent/Types.hs index a0f237d..f3f942e 100644 --- a/source/Network/Xmpp/Concurrent/Types.hs +++ b/source/Network/Xmpp/Concurrent/Types.hs @@ -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])]