-- TODO
-- this doesn't exit cleanly....
fromStream :: MonadIO m => Producer ByteString m x -> Producer Event m ()
fromStream p = do
  (evers, p') <- lift $ PP.runStateT (parseOne hmcvers) p
  case evers of
    Left s  -> liftIO $ print s
    Right v -> do
      liftIO . putStrLn $ "hepmc version: " ++ show v
      ex <- PA.parsed parserEvent p'
      case ex of
        Right _         -> liftIO $ print "no hepmc footer?!"
        Left (_, p'') -> do
          (exxx, _) <- lift $ PP.runStateT (parseOne hmcend) p''
          case exxx of
            Right _ -> liftIO $ putStrLn "finished."
            Left x  -> liftIO $ print x
fromStream :: MonadIO m => Producer ByteString m x -> Producer Event m ()
fromStream p = do
  (evers, p') <- lift $ PP.runStateT (parseOne hmcvers) p
  case evers of
    Left s  -> liftIO $ print s
    Right v -> do
      liftIO . putStrLn $ "hepmc version: " ++ show v
      ex <- PA.parsed parserEvent p'
      case ex of
        Right _         -> liftIO $ print "no hepmc footer?!"
        Left (_, p'') -> do
          (exxx, _) <- lift $ PP.runStateT (parseOne hmcend) p''
          case exxx of
            Right _ -> liftIO $ putStrLn "finished."
            Left x  -> liftIO $ print x
fromStream p = do
  (evers, p') <- lift $ PP.runStateT (parseOne hmcvers) p
  case evers of
    Left s  -> liftIO $ print s
    Right v -> do
      liftIO . putStrLn $ "hepmc version: " ++ show v
      ex <- PA.parsed parserEvent p'
      case ex of
        Right _         -> liftIO $ print "no hepmc footer?!"
        Left (_, p'') -> do
          (exxx, _) <- lift $ PP.runStateT (parseOne hmcend) p''
          case exxx of
            Right _ -> liftIO $ putStrLn "finished."
            Left x  -> liftIO $ print x