-- | Load a symbol from the dynamic library associated to the given namespace.
girSymbol :: forall a. Text -> Text -> IO (FunPtr a)
girSymbol ns symbol = do
  typelib <- withTextCString ns $ \cns ->
                    checkGError (g_irepository_require nullPtr cns nullPtr 0)
                                (error $ "Could not load typelib " ++ show ns)
  funPtrPtr <- allocMem :: IO (Ptr (FunPtr a))
  result <- withTextCString symbol $ \csymbol ->
                      g_typelib_symbol typelib csymbol funPtrPtr
  when (result /= 1) $
       error ("Could not resolve symbol " ++ show symbol ++ " in namespace "
              ++ show ns)
  funPtr <- peek funPtrPtr
  freeMem funPtrPtr
  return funPtr
girSymbol :: forall a. Text -> Text -> IO (FunPtr a)
girSymbol ns symbol = do
  typelib <- withTextCString ns $ \cns ->
                    checkGError (g_irepository_require nullPtr cns nullPtr 0)
                                (error $ "Could not load typelib " ++ show ns)
  funPtrPtr <- allocMem :: IO (Ptr (FunPtr a))
  result <- withTextCString symbol $ \csymbol ->
                      g_typelib_symbol typelib csymbol funPtrPtr
  when (result /= 1) $
       error ("Could not resolve symbol " ++ show symbol ++ " in namespace "
              ++ show ns)
  funPtr <- peek funPtrPtr
  freeMem funPtrPtr
  return funPtr
girSymbol ns symbol = do
  typelib <- withTextCString ns $ \cns ->
                    checkGError (g_irepository_require nullPtr cns nullPtr 0)
                                (error $ "Could not load typelib " ++ show ns)
  funPtrPtr <- allocMem :: IO (Ptr (FunPtr a))
  result <- withTextCString symbol $ \csymbol ->
                      g_typelib_symbol typelib csymbol funPtrPtr
  when (result /= 1) $
       error ("Could not resolve symbol " ++ show symbol ++ " in namespace "
              ++ show ns)
  funPtr <- peek funPtrPtr
  freeMem funPtrPtr
  return funPtr