module Exercise04 where import Data.List {-WETT-} xmlLight :: String -> Bool xmlLight text = groupBy is_b text `tagCheck` [] where is_b x y = notElem x "<>/" && notElem y "<>/" dr = dropWhile (== ' ') . reverse tagCheck ("<" : t : ">" : ts) ttc = tagCheck ts $ t : ttc tagCheck ("<" : "/" : t : ">" : ts) (tc : ttc) = dr tc == dr t && ' ' `notElem` dr t && tagCheck ts ttc tagCheck (t : ts) ttc = null (t `intersect` "<>") && tagCheck ts ttc tagCheck _ x = null x {-TTEW-}