import Text.XML.Expat.Chunked import Text.XML.Expat.Format import Control.Monad import Control.Monad.Trans import qualified Data.ByteString as B import Data.Iteratee import Data.List.Class import Data.Text (Text) import qualified Data.Text as T import System.IO main :: IO () main = do eErr <- fileDriver (parse defaultParserOptions dump) "sudoku.xml" case eErr of Left err -> putStrLn $ "failed: "++show err Right () -> putStrLn "" dump :: UNode IO Text -> XMLT IO () dump doc = do let txt = formatG doc execute $ forL txt $ liftIO . B.hPutStr stdout where mapL :: List c => (a -> ItemM c b) -> c a -> c b mapL f = joinM . liftM f joinM :: List c => c (ItemM c a) -> c a joinM = (>>= joinL . liftM return) forL = flip mapL