EventFile :: File f ⇒ f → IO (Maybe [Event])
readEventFile file = do
  fileContents ← decodeLatin1 . stripBoM . BS.toStrict <$> readFile file
  parseResult ← case statefulParseOnly (sep *> many' value) (initialPos $ fileName file) fileContents of
    Right x → return x
    Left x → trace ("Parse failed in " <> fileName file) $ Prelude.putStrLn (fileName file <> ": " <> show x) >> return []
  let events' = map (runMaker eventOrNamespace) parseResult
  mapM_ (printErrors file) events'
  return $ if isRight $ sequence events'
           then Just $ lefts $ rights events'
           else Nothing

-- checkFiles takes a list of file paths and checks the syntax in each of them.
-- If any errors are found, a summary of the files with errors is printed and
-- the program exits. If no errors are found, the function returns a list of all
-- the events parsed.
readEventFiles 
readEventFile :: File f ⇒ f → IO (Maybe [Event])
readEventFile file = do
  fileContents ← decodeLatin1 . stripBoM . BS.toStrict <$> readFile file
  parseResult ← case statefulParseOnly (sep *> many' value) (initialPos $ fileName file) fileContents of
    Right x → return x
    Left x → trace ("Parse failed in " <> fileName file) $ Prelude.putStrLn (fileName file <> ": " <> show x) >> return []
  let events' = map (runMaker eventOrNamespace) parseResult
  mapM_ (printErrors file) events'
  return $ if isRight $ sequence events'
           then Just $ lefts $ rights events'
           else Nothing

-- checkFiles takes a list of file paths and checks the syntax in each of them.
-- If any errors are found, a summary of the files with errors is printed and
-- the program exits. If no errors are found, the function returns a list of all
-- the events parsed.
readEventFile file = do
  fileContents ← decodeLatin1 . stripBoM . BS.toStrict <$> readFile file
  parseResult ← case statefulParseOnly (sep *> many' value) (initialPos $ fileName file) fileContents of
    Right x → return x
    Left x → trace ("Parse failed in " <> fileName file) $ Prelude.putStrLn (fileName file <> ": " <> show x) >> return []
  let events' = map (runMaker eventOrNamespace) parseResult
  mapM_ (printErrors file) events'
  return $ if isRight $ sequence events'
           then Just $ lefts $ rights events'
           else Nothing

-- checkFiles takes a list of file paths and checks the syntax in each of them.
-- If any errors are found, a summary of the files with errors is printed and
-- the program exits. If no errors are found, the function returns a list of all
-- the events parsed.