{-# LANGUAGE OverloadedStrings #-} module Exercise04 where import Data.List import Data.Text {-WETT-} xmlLight :: String -> Bool xmlLight [] = True xmlLight (x : xs) | x == '>' = False | x == '<' = "<" `splitOn` pack xs `xmlHelper` [] | otherwise = xmlLight xs xmlHelper :: [Text] -> [Text] -> Bool xmlHelper [] ys = Data.List.null ys xmlHelper (x : xs) ys = Data.List.length splited == 2 && Data.List.length tag == 1 && if Data.Text.head htag == '/' then ys /= [] && Data.Text.tail htag == Data.List.head ys && xs `xmlHelper` Data.List.tail ys else xmlHelper xs $htag : ys where splited = splitOn ">" x tag = Data.Text.words $ Data.List.head splited htag = Data.List.head tag {-MCCOMMENT: Falls doch noch Tests bzgl. führenden Leerzeichen und / hinzugefügt werden und xmlHelper nicht mehr funktioniert, dann bitte xmlHelper2 verwenden xmlHelper2 :: [Text] -> [Text] -> Bool xmlHelper2 [] ys = Data.List.null ys xmlHelper2 (x : xs) ys = Data.List.length splited == 2 && Data.List.length tag == 1 && htag /= "" && "/" `Data.Text.isInfixOf` Data.Text.tail htag /= True && if Data.Text.head htag == '/' then ys /= [] && Data.Text.tail htag == Data.List.head ys && xs `xmlHelper2` Data.List.tail ys else xmlHelper2 xs $htag : ys where splited = splitOn ">" x tag = splitOn " " $ Data.Text.stripEnd $ Data.List.head splited htag = Data.List.head tag -} {-TTEW-}