                        return (rate, format, flags, startType, start, stopType, stop)
                      | otherwise = Nothing
 
-eventParseTag :: Event
+eventParseTag :: EventClass event
+              => event
               -> Maybe TagList
 eventParseTag event | eventType event == EventTag =
     Just $ unsafePerformIO $ alloca $ \tagListPtr ->
-        do {# call event_parse_tag #} event (castPtr tagListPtr)
+        do {# call event_parse_tag #} (toEvent event) (castPtr tagListPtr)
            peek tagListPtr >>= peekTagList
+                    | otherwise = Nothing
 
 eventTypeGetName :: EventType
                  -> String

               return (format, minSize, maxSize, async)
                           | otherwise = Nothing

eventParseLatency :: Event
                  -> Maybe ClockTime
eventParseLatency event | eventType event == EventLatency =
    Just $ unsafePerformIO $ alloca $ \latencyPtr ->
        do {# call event_parse_latency #} event
                                          latencyPtr
           liftM fromIntegral $ peek latencyPtr
                        | otherwise = Nothing

eventParseNewSegment :: Event
                     -> Maybe (Bool, Double, Format, Int64, Int64, Int64)
eventParseNewSegment event | eventType event == EventNewSegment =
    Just $ unsafePerformIO $ alloca $ \updatePtr ->
        alloca $ \ratePtr -> alloca $ \formatPtr ->
            alloca $ \startPtr -> alloca $ \stopPtr ->
                alloca $ \positionPtr ->
                    do {# call event_parse_new_segment #} event
                                                          ratePtr
                                                          updatePtr
                                                          formatPtr

               return (proportion, diff, timestamp)
                    | otherwise = Nothing

eventParseSeek :: EventClass event
               => event
               -> Maybe (Double, Format, [SeekFlags], SeekType, Int64, SeekType, Int64)
eventParseSeek event | eventType event == EventSeek =
    Just $ unsafePerformIO $ alloca $ \ratePtr ->
        alloca $ \formatPtr -> alloca $ \flagsPtr ->
            alloca $ \startTypePtr -> alloca $ \startPtr ->
                alloca $ \stopTypePtr -> alloca $ \stopPtr ->
                    do {# call event_parse_seek #} (toEvent event)
                                                   ratePtr
                                                   formatPtr
                                                   flagsPtr
