module Text.XMLHTML.Internal where
import Control.Exception (SomeException)
import Instances.TH.Lift ()
import Language.Haskell.TH (Q, Exp)
import Language.Haskell.TH.Lift (deriveLiftMany)
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Text.XML
(Doctype(..), Document(..), Element(..), ExternalID(..),
Instruction(..), Miscellaneous(..), Name(..), Node(..),
Prologue(..))
$(deriveLiftMany
[ ''ExternalID
, ''Node
, ''Name
, ''Instruction
, ''Doctype
, ''Element
, ''Miscellaneous
, ''Prologue
, ''Document
])
createExpQuasiQuoter
:: (String -> Q Exp)
-> QuasiQuoter
createExpQuasiQuoter f =
QuasiQuoter
{ quoteExp = f
, quotePat = error "not used"
, quoteType = error "not used"
, quoteDec = error "not used"
}
handleParseDocErr
:: String
-> String
-> String
-> SomeException
-> a
handleParseDocErr docType parseFunction string exception =
let msg =
"ERROR: Trying to parse a string into an " `mappend`
docType `mappend`
" Document,\n" `mappend`
"but got the following error from " `mappend`
parseFunction `mappend`
":\n" `mappend`
show exception `mappend`
"\n" `mappend`
"attempting to parse the following document:\n" `mappend`
string
in error msg