 type CharacterDataHandler = String -> IO ()
 
 type CStartElementHandler = Ptr () -> CString -> Ptr CString -> IO ()
+nullCStartElementHandler _ _ _ = return ()
+
 foreign import ccall "wrapper"
   mkCStartElementHandler :: CStartElementHandler
                          -> IO (FunPtr CStartElementHandler)
-wrapStartElementHandler :: StartElementHandler
-                        -> IO (FunPtr CStartElementHandler)
-wrapStartElementHandler handler = mkCStartElementHandler h where
+wrapStartElementHandler :: StartElementHandler -> CStartElementHandler
+wrapStartElementHandler handler = h where
   h ptr cname cattrs = do
     name <- peekCString cname
     cattrlist <- peekArray0 nullPtr cattrs

  encodingToString
) where

import C2HS
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL

#include <expat.h>



-- |Opaque parser type.
type ParserPtr = Ptr ()
data Parser = Parser
    (ForeignPtr ())
    (IORef CStartElementHandler) 
    (IORef CEndElementHandler) 
    (IORef CCharacterDataHandler) 

withParser :: Parser -> (ParserPtr -> IO a) -> IO a
withParser (Parser fp _ _ _) = withForeignPtr fp

-- |Encoding types available for the document encoding.
data Encoding = ASCII | UTF8 | UTF16 | ISO88591
