import Data.Char import Data.List import Control.Applicative bool :: a -> a -> Bool -> a bool t e b = if b then t else e analyseLine :: (Int, String) -> [String] analyseLine (line, xs) | any (not . isAscii) xs = ["Line " ++ show line, " Orig: " ++ xs, " Mark: " ++ marks xs, " Char: " ++ chars xs] | otherwise = [] where marks = reverse . dropWhile isSpace . reverse . map (bool ' ' '^' . isAscii) chars = intercalate ", " . map show . filter (not . isAscii) main :: IO () main = do putStrLn "Reading from stdin" putStrLn =<< unlines . concatMap analyseLine . zip [1..] . lines <$> getContents