module Exercise04 where import Data.Char ( isSpace ) {-WETT-} xmlLight :: String -> Bool xmlLight xs = mainParse xs [] mainParse :: String -> [String] -> Bool -- Closing Tags mainParse ('<' : '/' : xs) (ts: tss) = let (rs, ts') = tagId xs in (ts' == ts) && mainParse rs tss mainParse ('<' : '/' : _) [] = False mainParse ('>' : _) _ = False -- Opening Tag mainParse ('<' : xs) tss = let (rs, ts) = tagId xs in mainParse rs (ts : tss) -- Plain Text mainParse (_ : xss) tss = mainParse xss tss -- End of String mainParse [] tss = null tss -- Input -> (remaining String, TagID) tagId :: String -> (String, String) tagId ('>' : xs) = (xs, []) tagId ('<' : _) = (">", []) tagId (x : xs) | isSpace x && null ts = res | isSpace x = (">", []) | otherwise = (rs, x : ts) where res@(rs , ts) = tagId xs tagId [] = (">", []) --return ">" character that will always evaluate to false {-TTEW-}