X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=hxt-compile.git;a=blobdiff_plain;f=Text%2FXML%2FHXT%2FCompilation.hs;h=c2428de92137d65c3e6904bf749b96ed35337224;hp=cbcf396b03b57baaabf0eda579874b4c1c77e3e8;hb=13dc5a370f4d7d3223937346fc63ce94c8aa85a8;hpb=5ccdec1d86b750444704312526a44eb68972027b diff --git a/Text/XML/HXT/Compilation.hs b/Text/XML/HXT/Compilation.hs index cbcf396..c2428de 100644 --- a/Text/XML/HXT/Compilation.hs +++ b/Text/XML/HXT/Compilation.hs @@ -11,6 +11,8 @@ import Text.XML.HXT.Compilation.XmlTree compileDocument :: ArrowXml a => a XmlTree (HsQualType, HsExp) compileDocument = uniqueNamespacesFromDeclAndQNames + >>> + filterOutRootAttrs >>> ( constA (HsQualType [] (HsTyCon (UnQual (HsIdent "XmlTree")))) &&& @@ -18,13 +20,19 @@ compileDocument = uniqueNamespacesFromDeclAndQNames ) -wrapIntoModule :: Arrow a => a (Module, (HsName, (HsQualType, HsExp))) HsModule -wrapIntoModule = proc (modName, (symName, (symType, symExp))) -> +filterOutRootAttrs :: ArrowXml a => a XmlTree XmlTree +filterOutRootAttrs = processTopDownUntil (clearAttrs `when` isRoot) + where + clearAttrs = processAttrl none + + +wrapIntoModule :: Arrow a => a (Module, ([HsImportDecl], (HsName, (HsQualType, HsExp)))) HsModule +wrapIntoModule = proc (modName, (extImports, (symName, (symType, symExp)))) -> do let hsModule = HsModule undefined modName (Just exports) imports decls exports = [HsEVar (UnQual symName)] imports = [ HsImportDecl undefined (Module "Text.XML.HXT.Arrow") False Nothing Nothing , HsImportDecl undefined (Module "Text.XML.HXT.DOM.XmlNode") True (Just (Module "XN")) Nothing - ] + ] ++ extImports decls = [ HsTypeSig undefined [symName] symType , HsFunBind [HsMatch undefined symName [] (HsUnGuardedRhs symExp) []] ]