{-# LANGUAGE BlockArguments #-} module Exercise04 where import Data.Char ( isAlphaNum ) import Text.ParserCombinators.ReadP {-MCCOMMENT This submission makes use of a little-known gold nugget in the base library: The ReadP parser combinators. While the independent parser libraries such as {mega,atto,}parsec and so on are well-known and widely used, the ReadP combinators are mainly used behind the scenes to implement instances for the Read typeclass. But why does nobody use ReadP? Probably because it does not live up to the performance, scope and comfort provided by the "real" parsecs. Another reason might be the sorting order of the module list on Hackage: Starting with "Text", the ReadP module simply appears after a large chunk of other modules, including Control, Data, GHC and System - in other words, you have to scroll all the way down in order to find ReadP, and if you don't know what to look for, you won't find ReadP. Obviously, both peculiarities don't matter for the Wettbewerb! Another ~~dirty trick~~ readability improvement is the BlockArguments extension: It allows dropping the $ before the do statements, saving 2 tokens. -} {-WETT-} xmlLight :: String -> Bool xmlLight = not . null . readP_to_S do let innerP = satisfy (`notElem` "<>") +++ do char '<' id1 <- munch1 isAlphaNum skipSpaces char '>' skipMany innerP string "' skipMany innerP eof {-TTEW-}