 
 extensionPresent :: ExtensionInfo -> IO Bool
 extensionPresent (ExtensionInfo ext)
-    = liftM toBool $ {#get query_extension_reply_t->present#} ext
+    = toBool <$> {#get query_extension_reply_t->present#} ext
 
 extensionMajorOpcode :: ExtensionInfo -> IO Word8
 extensionMajorOpcode (ExtensionInfo ext)
-    = liftM fromIntegral $ {#get query_extension_reply_t->major_opcode#} ext
+    = fromIntegral <$> {#get query_extension_reply_t->major_opcode#} ext
 
 extensionFirstEvent :: ExtensionInfo -> IO Word8
 extensionFirstEvent (ExtensionInfo ext)
-    = liftM fromIntegral $ {#get query_extension_reply_t->first_event#} ext
+    = fromIntegral <$> {#get query_extension_reply_t->first_event#} ext
 
 extensionFirstError :: ExtensionInfo -> IO Word8
 extensionFirstError (ExtensionInfo ext)
-    = liftM fromIntegral $ {#get query_extension_reply_t->first_error#} ext
+    = fromIntegral <$> {#get query_extension_reply_t->first_error#} ext
 
 -- | Non-blocking query for extension data
 prefetchExtension :: Connection -> Extension -> IO ()

-- | Returns the length of the reply in units of four bytes
replyLength :: GenericReply -> IO Word32
replyLength rep = withGenericReply rep $ \repPtr -> do
                  lenField <- liftM fromIntegral $ {#get generic_reply_t->length#} repPtr
                  return $ lenField + 1 -- for the inserted full_sequence field

instance HasResponseType GenericReply where


-- | Length of the setup data in units of four bytes.
setupLength :: Setup -> IO Word16
setupLength (Setup s) = fromIntegral <$> {#get setup_t->length#} s

-- | This ByteString is just as unsafe as the passed in connection
-- object.  Please make a copy.
unsafeSetupData :: Setup -> IO S.ByteString
unsafeSetupData s@(Setup sPtr) = do
  len <- (4*) <$> setupLength s
  sFPtr <- newForeignPtr_ sPtr
  return $ S.fromForeignPtr (castForeignPtr sFPtr) 0 (fromIntegral len)

