{-
Example program for TagSoup.
Detects basic syntax errors like isolated ampersands and unquoted attribute values.
-}
module Main where

import Text.HTML.TagSoup
import qualified Text.HTML.TagSoup.Position as Position

import System.Environment (getArgs)

import Data.Maybe (mapMaybe)


validate :: FilePath -> String -> String
validate fileName input =
   let tags :: [PosTag Char]
       tags = parseFilePosTags fileName input
       warnings =
          mapMaybe (\(pos,tag) -> fmap ((,) pos) $ maybeTagWarning tag) tags
   in  unlines $ map (\(pos,msg) -> Position.toReportText pos ++ " " ++ msg) warnings

validateIO :: FilePath -> IO ()
validateIO fileName =
   do text <- readFile fileName
      putStrLn (validate fileName text)


main :: IO ()
main = mapM_ validateIO =<< getArgs

{-
Example program for TagSoup.
Detects basic syntax errors like isolated ampersands and unquoted attribute values.
-}
module Main where

import Text.HTML.TagSoup
import Text.HTML.TagSoup.Position
import System.Environment


validate :: FilePath -> String -> String
validate file input = unlines
    [toReportText (setFileName file pos) ++ " " ++ msg
    | TagPos pos (TagWarning msg) <- parseTagsGeneric input :: [TagPos Char]]

validateIO :: FilePath -> IO ()
validateIO file =
   do text <- readFile file
      putStrLn (validate file text)


main :: IO ()
main = mapM_ validateIO =<< getArgs

Change the validate example to do the same thing, but be more simple
Change the validate example to do the same thing, but be more simple