-- A helper module to convert XML produced by Erlang's TypEr application -- to Haskell code to call Erlang functions with proper type annotations. -- This module implements a Parsec-based parser for XML that was converted -- by parsing the output from TypEr. -- First, XML (provided as a string) is processed by TagSoup, resulting in a list of tags -- as the XML tree is traversed. Next, Parsec-based part converts the list of tags -- into an internal representation. Finally, Haskell pretty-printer -- generates Haskell source that contains code to call Erlang functions specified by Edoc. module Language.Edoc.TyXml2Hs ( xml2hs) where import Text.HTML.TagSoup import Text.HTML.TagSoup.Parser import Text.ParserCombinators.Parsec import Language.Haskell.Pretty import Language.Edoc.Xml2Hs.Type import Language.Edoc.Xml2Hs.Parser import Language.Edoc.Xml2Hs.TyParser import Language.Edoc.Xml2Hs.Haskell -- |The main function: takes XML as a string and returns Haskell as a string. -- Parsing errors will be thrown as exceptions if occur. xml2hs :: String -> String xml2hs xml = let tags = parseTags xml parsed = either (error . show) id $ runParser (pTyMod "ErlImport") PState {counter = 0} "" tags hmod = edoc2mod parsed in prettyPrint hmod