stream :: ByteString -> ByteString -> (ByteString, [StreamingPayload])
stream i a | isThump i = ("", [Thump])
           | isEvent i = (i, [])
           | otherwise = parseE a i
  where parseE et d =
          case parseET et of
            (Just EDelete) -> ("", p parseDelete d)
            (Just ENotification) -> ("", p parseNotification d)
            (Just EUpdate) -> ("",p parseUpdate d)
            Nothing -> ("", [])
        p r s = maybeToList $ maybeResult $ parse r s
        isThump = (":thump" `B8.isPrefixOf`)
        isEvent = ("event: " `B8.isPrefixOf`)
        parseET s = maybeResult $ parse parseEvent s
stream :: ByteString -> ByteString -> (ByteString, [StreamingPayload])
stream i a | isThump i = ("", [Thump])
           | isEvent i = (i, [])
           | otherwise = parseE a i
  where parseE et d =
          case parseET et of
            (Just EDelete) -> ("", p parseDelete d)
            (Just ENotification) -> ("", p parseNotification d)
            (Just EUpdate) -> ("",p parseUpdate d)
            Nothing -> ("", [])
        p r s = maybeToList $ maybeResult $ parse r s
        isThump = (":thump" `B8.isPrefixOf`)
        isEvent = ("event: " `B8.isPrefixOf`)
        parseET s = maybeResult $ parse parseEvent s
stream i a | isThump i = ("", [Thump])
           | isEvent i = (i, [])
           | otherwise = parseE a i
  where parseE et d =
          case parseET et of
            (Just EDelete) -> ("", p parseDelete d)
            (Just ENotification) -> ("", p parseNotification d)
            (Just EUpdate) -> ("",p parseUpdate d)
            Nothing -> ("", [])
        p r s = maybeToList $ maybeResult $ parse r s
        isThump = (":thump" `B8.isPrefixOf`)
        isEvent = ("event: " `B8.isPrefixOf`)
        parseET s = maybeResult $ parse parseEvent s