readFinalVSEOutput :: ProcessHandle -> Handle
                   -> IO (Maybe (Map.Map String [String]))
readFinalVSEOutput cp out = do
  ms <- getProcessExitCode cp
  case ms of
    Just _ -> do
      appendFile vseErrFile "hetsvse unavailable\n"
      return Nothing
    Nothing -> do
      revres <- readRest cp out ""
      let res = reverse revres
      writeFile "hetsvse-debug.txt" res
      case parse parseSExprs vseErrFile res of
        Right l -> return $ Just $ readLemmas l
        Left e -> do
          print e
          appendFile vseErrFile $ res ++ "\n"
          return Nothing
readFinalVSEOutput :: ProcessHandle -> Handle
                   -> IO (Maybe (Map.Map String [String]))
readFinalVSEOutput cp out = do
  ms <- getProcessExitCode cp
  case ms of
    Just _ -> do
      appendFile vseErrFile "hetsvse unavailable\n"
      return Nothing
    Nothing -> do
      revres <- readRest cp out ""
      let res = reverse revres
      writeFile "hetsvse-debug.txt" res
      case parse parseSExprs vseErrFile res of
        Right l -> return $ Just $ readLemmas l
        Left e -> do
          print e
          appendFile vseErrFile $ res ++ "\n"
          return Nothing
readFinalVSEOutput cp out = do
  ms <- getProcessExitCode cp
  case ms of
    Just _ -> do
      appendFile vseErrFile "hetsvse unavailable\n"
      return Nothing
    Nothing -> do
      revres <- readRest cp out ""
      let res = reverse revres
      writeFile "hetsvse-debug.txt" res
      case parse parseSExprs vseErrFile res of
        Right l -> return $ Just $ readLemmas l
        Left e -> do
          print e
          appendFile vseErrFile $ res ++ "\n"
          return Nothing