diff --git a/patched/Graphics/XHB/Gen/Composite/Types.hs b/patched/Graphics/XHB/Gen/Composite/Types.hs
--- a/patched/Graphics/XHB/Gen/Composite/Types.hs
+++ b/patched/Graphics/XHB/Gen/Composite/Types.hs
@@ -34,6 +34,7 @@
  
 data Redirect = RedirectAutomatic
               | RedirectManual
+              deriving Show
  
 instance SimpleEnum Redirect where
         toValue RedirectAutomatic{} = 0
diff --git a/patched/Graphics/XHB/Gen/Damage/Types.hs b/patched/Graphics/XHB/Gen/Damage/Types.hs
--- a/patched/Graphics/XHB/Gen/Damage/Types.hs
+++ b/patched/Graphics/XHB/Gen/Damage/Types.hs
@@ -38,6 +38,7 @@
                  | ReportLevelDeltaRectangles
                  | ReportLevelBoundingBox
                  | ReportLevelNonEmpty
+                 deriving Show
  
 instance SimpleEnum ReportLevel where
         toValue ReportLevelRawRectangles{} = 0
diff --git a/patched/Graphics/XHB/Gen/Glx/Types.hs b/patched/Graphics/XHB/Gen/Glx/Types.hs
--- a/patched/Graphics/XHB/Gen/Glx/Types.hs
+++ b/patched/Graphics/XHB/Gen/Glx/Types.hs
@@ -419,6 +419,7 @@
  
 data PBCET = PBCETDamaged
            | PBCETSaved
+           deriving Show
  
 instance SimpleEnum PBCET where
         toValue PBCETDamaged{} = 32791
@@ -428,6 +429,7 @@
  
 data PBCDT = PBCDTWindow
            | PBCDTPbuffer
+           deriving Show
  
 instance SimpleEnum PBCDT where
         toValue PBCDTWindow{} = 32793
@@ -688,6 +690,7 @@
         | GCGL_LIST_BIT
         | GCGL_TEXTURE_BIT
         | GCGL_SCISSOR_BIT
+        deriving Show
  
 instance BitEnum GC where
         toBit GCGL_CURRENT_BIT{} = 0
@@ -1481,6 +1484,7 @@
 data RM = RMGL_RENDER
         | RMGL_FEEDBACK
         | RMGL_SELECT
+        deriving Show
  
 instance SimpleEnum RM where
         toValue RMGL_RENDER{} = 7168
diff --git a/patched/Graphics/XHB/Gen/Input/Types.hs b/patched/Graphics/XHB/Gen/Input/Types.hs
--- a/patched/Graphics/XHB/Gen/Input/Types.hs
+++ b/patched/Graphics/XHB/Gen/Input/Types.hs
@@ -109,6 +109,7 @@
  
 data ValuatorMode = ValuatorModeRelative
                   | ValuatorModeAbsolute
+                  deriving Show
  
 instance SimpleEnum ValuatorMode where
         toValue ValuatorModeRelative{} = 0
@@ -118,6 +119,7 @@
  
 data PropagateMode = PropagateModeAddToList
                    | PropagateModeDeleteFromList
+                   deriving Show
  
 instance SimpleEnum PropagateMode where
         toValue PropagateModeAddToList{} = 0
@@ -228,6 +230,7 @@
                | DeviceUseIsXExtensionDevice
                | DeviceUseIsXExtensionKeyboard
                | DeviceUseIsXExtensionPointer
+               deriving Show
  
 instance SimpleEnum DeviceUse where
         toValue DeviceUseIsXPointer{} = 0
@@ -415,6 +418,7 @@
                 | InputClassProximity
                 | InputClassFocus
                 | InputClassOther
+                deriving Show
  
 instance SimpleEnum InputClass where
         toValue InputClassKey{} = 0
diff --git a/patched/Graphics/XHB/Gen/RandR/Types.hs b/patched/Graphics/XHB/Gen/RandR/Types.hs
--- a/patched/Graphics/XHB/Gen/RandR/Types.hs
+++ b/patched/Graphics/XHB/Gen/RandR/Types.hs
@@ -61,6 +61,7 @@
               | RotationRotate_270
               | RotationReflect_X
               | RotationReflect_Y
+              deriving Show
  
 instance BitEnum Rotation where
         toBit RotationRotate_0{} = 0
@@ -214,6 +215,7 @@
                | SetConfigInvalidConfigTime
                | SetConfigInvalidTime
                | SetConfigFailed
+               deriving Show
  
 instance SimpleEnum SetConfig where
         toValue SetConfigSuccess{} = 0
@@ -378,6 +380,7 @@
               | ModeFlagPixelMultiplex
               | ModeFlagDoubleClock
               | ModeFlagHalveClock
+              deriving Show
  
 instance BitEnum ModeFlag where
         toBit ModeFlagHsyncPositive{} = 0
@@ -536,6 +539,7 @@
 data Connection = ConnectionConnected
                 | ConnectionDisconnected
                 | ConnectionUnknown
+                deriving Show
  
 instance SimpleEnum Connection where
         toValue ConnectionConnected{} = 0
@@ -1116,6 +1120,7 @@
                 | NotifyMaskCrtcChange
                 | NotifyMaskOutputChange
                 | NotifyMaskOutputProperty
+                deriving Show
  
 instance BitEnum NotifyMask where
         toBit NotifyMaskScreenChange{} = 0
@@ -1169,8 +1174,9 @@
                     mheight)
  
 data NotifyEnum = NotifyCrtcChange
-                | NotifyOutputChange
-                | NotifyOutputProperty
+            | NotifyOutputChange
+            | NotifyOutputProperty
+            deriving Show
  
 instance SimpleEnum NotifyEnum where
         toValue NotifyCrtcChange{} = 0
diff --git a/patched/Graphics/XHB/Gen/Record/Types.hs b/patched/Graphics/XHB/Gen/Record/Types.hs
--- a/patched/Graphics/XHB/Gen/Record/Types.hs
+++ b/patched/Graphics/XHB/Gen/Record/Types.hs
@@ -130,6 +130,7 @@
 data HType = HTypeFromServerTime
            | HTypeFromClientTime
            | HTypeFromClientSequence
+           deriving Show
  
 instance BitEnum HType where
         toBit HTypeFromServerTime{} = 0
@@ -144,6 +145,7 @@
 data CS = CSCurrentClients
         | CSFutureClients
         | CSAllClients
+        deriving Show
  
 instance SimpleEnum CS where
         toValue CSCurrentClients{} = 1
diff --git a/patched/Graphics/XHB/Gen/Render/Types.hs b/patched/Graphics/XHB/Gen/Render/Types.hs
--- a/patched/Graphics/XHB/Gen/Render/Types.hs
+++ b/patched/Graphics/XHB/Gen/Render/Types.hs
@@ -44,6 +44,7 @@
  
 data PictType = PictTypeIndexed
               | PictTypeDirect
+              deriving Show
  
 instance SimpleEnum PictType where
         toValue PictTypeIndexed{} = 0
@@ -89,6 +90,7 @@
             | PictOpConjointAtop
             | PictOpConjointAtopReverse
             | PictOpConjointXor
+            deriving Show
  
 instance SimpleEnum PictOp where
         toValue PictOpClear{} = 0
@@ -170,6 +172,7 @@
  
 data PolyEdge = PolyEdgeSharp
               | PolyEdgeSmooth
+              deriving Show
  
 instance SimpleEnum PolyEdge where
         toValue PolyEdgeSharp{} = 0
@@ -179,6 +182,7 @@
  
 data PolyMode = PolyModePrecise
               | PolyModeImprecise
+              deriving Show
  
 instance SimpleEnum PolyMode where
         toValue PolyModePrecise{} = 0
@@ -199,6 +203,7 @@
         | CPPolyMode
         | CPDither
         | CPComponentAlpha
+        deriving Show
  
 instance BitEnum CP where
         toBit CPRepeat{} = 0
@@ -234,6 +239,7 @@
               | SubPixelVerticalRGB
               | SubPixelVerticalBGR
               | SubPixelNone
+              deriving Show
  
 instance SimpleEnum SubPixel where
         toValue SubPixelUnknown{} = 0
@@ -253,6 +259,7 @@
             | RepeatNormal
             | RepeatPad
             | RepeatReflect
+            deriving Show
  
 instance SimpleEnum Repeat where
         toValue RepeatNone{} = 0
diff --git a/patched/Graphics/XHB/Gen/ScreenSaver/Types.hs b/patched/Graphics/XHB/Gen/ScreenSaver/Types.hs
--- a/patched/Graphics/XHB/Gen/ScreenSaver/Types.hs
+++ b/patched/Graphics/XHB/Gen/ScreenSaver/Types.hs
@@ -31,6 +31,7 @@
 data Kind = KindBlanked
           | KindInternal
           | KindExternal
+          deriving Show
  
 instance SimpleEnum Kind where
         toValue KindBlanked{} = 0
@@ -42,6 +43,7 @@
  
 data Event = EventNotifyMask
            | EventCycleMask
+           deriving Show
  
 instance BitEnum Event where
         toBit EventNotifyMask{} = 0
@@ -53,6 +55,7 @@
            | StateOn
            | StateCycle
            | StateDisabled
+           deriving Show
  
 instance SimpleEnum State where
         toValue StateOff{} = 0
diff --git a/patched/Graphics/XHB/Gen/Shape/Types.hs b/patched/Graphics/XHB/Gen/Shape/Types.hs
--- a/patched/Graphics/XHB/Gen/Shape/Types.hs
+++ b/patched/Graphics/XHB/Gen/Shape/Types.hs
@@ -39,6 +39,7 @@
         | SOIntersect
         | SOSubtract
         | SOInvert
+        deriving Show
  
 instance SimpleEnum SO where
         toValue SOSet{} = 0
@@ -55,6 +56,7 @@
 data SK = SKBounding
         | SKClip
         | SKInput
+        deriving Show
  
 instance SimpleEnum SK where
         toValue SKBounding{} = 0
diff --git a/patched/Graphics/XHB/Gen/Sync/Types.hs b/patched/Graphics/XHB/Gen/Sync/Types.hs
--- a/patched/Graphics/XHB/Gen/Sync/Types.hs
+++ b/patched/Graphics/XHB/Gen/Sync/Types.hs
@@ -47,6 +47,7 @@
 data ALARMSTATE = ALARMSTATEActive
                 | ALARMSTATEInactive
                 | ALARMSTATEDestroyed
+                deriving Show
  
 instance SimpleEnum ALARMSTATE where
         toValue ALARMSTATEActive{} = 0
@@ -63,6 +64,7 @@
               | TESTTYPENegativeTransition
               | TESTTYPEPositiveComparison
               | TESTTYPENegativeComparison
+              deriving Show
  
 instance SimpleEnum TESTTYPE where
         toValue TESTTYPEPositiveTransition{} = 0
@@ -76,6 +78,7 @@
  
 data VALUETYPE = VALUETYPEAbsolute
                | VALUETYPERelative
+               deriving Show
  
 instance SimpleEnum VALUETYPE where
         toValue VALUETYPEAbsolute{} = 0
@@ -89,6 +92,7 @@
         | CATestType
         | CADelta
         | CAEvents
+        deriving Show
  
 instance BitEnum CA where
         toBit CACounter{} = 0
diff --git a/patched/Graphics/XHB/Gen/Test/Types.hs b/patched/Graphics/XHB/Gen/Test/Types.hs
--- a/patched/Graphics/XHB/Gen/Test/Types.hs
+++ b/patched/Graphics/XHB/Gen/Test/Types.hs
@@ -60,6 +60,7 @@
  
 data Cursor = CursorNone
             | CursorCurrent
+            deriving Show
  
 instance SimpleEnum Cursor where
         toValue CursorNone{} = 0
diff --git a/patched/Graphics/XHB/Gen/XFixes/Types.hs b/patched/Graphics/XHB/Gen/XFixes/Types.hs
--- a/patched/Graphics/XHB/Gen/XFixes/Types.hs
+++ b/patched/Graphics/XHB/Gen/XFixes/Types.hs
@@ -90,6 +90,7 @@
  
 data SaveSetMode = SaveSetModeInsert
                  | SaveSetModeDelete
+                 deriving Show
  
 instance SimpleEnum SaveSetMode where
         toValue SaveSetModeInsert{} = 0
@@ -99,6 +100,7 @@
  
 data SaveSetTarget = SaveSetTargetNearest
                    | SaveSetTargetRoot
+                   deriving Show
  
 instance SimpleEnum SaveSetTarget where
         toValue SaveSetTargetNearest{} = 0
@@ -108,6 +110,7 @@
  
 data SaveSetMapping = SaveSetMappingMap
                     | SaveSetMappingUnmap
+                    deriving Show
  
 instance SimpleEnum SaveSetMapping where
         toValue SaveSetMappingMap{} = 0
@@ -141,6 +144,7 @@
 data SelectionEvent = SelectionEventSetSelectionOwner
                     | SelectionEventSelectionWindowDestroy
                     | SelectionEventSelectionClientClose
+                    deriving Show
  
 instance SimpleEnum SelectionEvent where
         toValue SelectionEventSetSelectionOwner{} = 0
@@ -153,6 +157,7 @@
 data SelectionEventMask = SelectionEventMaskSetSelectionOwner
                         | SelectionEventMaskSelectionWindowDestroy
                         | SelectionEventMaskSelectionClientClose
+                        deriving Show
  
 instance BitEnum SelectionEventMask where
         toBit SelectionEventMaskSetSelectionOwner{} = 0
@@ -210,12 +215,14 @@
                putSkip (requiredPadding size__)
  
 data CursorNotifyEnum = CursorNotifyDisplayCursor
+                  deriving Show
  
 instance SimpleEnum CursorNotifyEnum where
         toValue CursorNotifyDisplayCursor{} = 0
         fromValue 0 = CursorNotifyDisplayCursor
  
 data CursorNotifyMask = CursorNotifyMaskDisplayCursor
+                      deriving Show
  
 instance BitEnum CursorNotifyMask where
         toBit CursorNotifyMaskDisplayCursor{} = 0
diff --git a/patched/Graphics/XHB/Gen/XPrint/Types.hs b/patched/Graphics/XHB/Gen/XPrint/Types.hs
--- a/patched/Graphics/XHB/Gen/XPrint/Types.hs
+++ b/patched/Graphics/XHB/Gen/XPrint/Types.hs
@@ -76,6 +76,7 @@
  
 data GetDoc = GetDocFinished
             | GetDocSecondConsumer
+            deriving Show
  
 instance SimpleEnum GetDoc where
         toValue GetDocFinished{} = 0
@@ -85,6 +86,7 @@
  
 data EvMask = EvMaskPrintMask
             | EvMaskAttributeMask
+            deriving Show
  
 instance BitEnum EvMask where
         toBit EvMaskPrintMask{} = 0
@@ -98,6 +100,7 @@
             | DetailEndDocNotify
             | DetailStartPageNotify
             | DetailEndPageNotify
+            deriving Show
  
 instance SimpleEnum Detail where
         toValue DetailStartJobNotify{} = 1
@@ -120,6 +123,7 @@
           | AttrServerAttr
           | AttrMediumAttr
           | AttrSpoolerAttr
+          deriving Show
  
 instance SimpleEnum Attr where
         toValue AttrJobAttr{} = 1
diff --git a/patched/Graphics/XHB/Gen/Xevie/Types.hs b/patched/Graphics/XHB/Gen/Xevie/Types.hs
--- a/patched/Graphics/XHB/Gen/Xevie/Types.hs
+++ b/patched/Graphics/XHB/Gen/Xevie/Types.hs
@@ -113,6 +113,7 @@
  
 data Datatype = DatatypeUnmodified
               | DatatypeModified
+              deriving Show
  
 instance SimpleEnum Datatype where
         toValue DatatypeUnmodified{} = 0
diff --git a/patched/Graphics/XHB/Gen/Xproto.hs b/patched/Graphics/XHB/Gen/Xproto.hs
--- a/patched/Graphics/XHB/Gen/Xproto.hs
+++ b/patched/Graphics/XHB/Gen/Xproto.hs
@@ -81,7 +81,7 @@
  
 changeSaveSet ::
                 Graphics.XHB.Connection.Types.Connection ->
-                  Word8 -> WINDOW -> IO ()
+                  SetMode -> WINDOW -> IO ()
 changeSaveSet c mode window
   = do let req = MkChangeSaveSet mode window
        let chunk = runPut (serialize req)
@@ -131,7 +131,7 @@
  
 circulateWindow ::
                   Graphics.XHB.Connection.Types.Connection ->
-                    Word8 -> WINDOW -> IO ()
+                    Circulate -> WINDOW -> IO ()
 circulateWindow c direction window
   = do let req = MkCirculateWindow direction window
        let chunk = runPut (serialize req)
@@ -242,7 +242,7 @@
  
 grabPointer ::
               Graphics.XHB.Connection.Types.Connection ->
-                GrabPointer -> IO (Receipt Word8)
+                GrabPointer -> IO (Receipt GrabStatus)
 grabPointer c req
   = do (receipt, rReceipt) <- newEmptyReceipt
                                 (runGet (status_GrabPointerReply `fmap` deserialize))
@@ -278,7 +278,7 @@
  
 grabKeyboard ::
                Graphics.XHB.Connection.Types.Connection ->
-                 GrabKeyboard -> IO (Receipt Word8)
+                 GrabKeyboard -> IO (Receipt GrabStatus)
 grabKeyboard c req
   = do (receipt, rReceipt) <- newEmptyReceipt
                                 (runGet (status_GrabKeyboardReply `fmap` deserialize))
@@ -307,7 +307,7 @@
  
 allowEvents ::
               Graphics.XHB.Connection.Types.Connection ->
-                Word8 -> TIMESTAMP -> IO ()
+                Allow -> TIMESTAMP -> IO ()
 allowEvents c mode time
   = do let req = MkAllowEvents mode time
        let chunk = runPut (serialize req)
@@ -868,21 +868,21 @@
        return receipt
  
 setAccessControl ::
-                   Graphics.XHB.Connection.Types.Connection -> Word8 -> IO ()
+                   Graphics.XHB.Connection.Types.Connection -> AccessControl -> IO ()
 setAccessControl c mode
   = do let req = MkSetAccessControl mode
        let chunk = runPut (serialize req)
        sendRequest c chunk
  
 setCloseDownMode ::
-                   Graphics.XHB.Connection.Types.Connection -> Word8 -> IO ()
+                   Graphics.XHB.Connection.Types.Connection -> CloseDown -> IO ()
 setCloseDownMode c mode
   = do let req = MkSetCloseDownMode mode
        let chunk = runPut (serialize req)
        sendRequest c chunk
  
 killClient ::
-             Graphics.XHB.Connection.Types.Connection -> Word32 -> IO ()
+             Graphics.XHB.Connection.Types.Connection -> Kill -> IO ()
 killClient c resource
   = do let req = MkKillClient resource
        let chunk = runPut (serialize req)
@@ -896,7 +896,7 @@
        sendRequest c chunk
  
 forceScreenSaver ::
-                   Graphics.XHB.Connection.Types.Connection -> Word8 -> IO ()
+                   Graphics.XHB.Connection.Types.Connection -> ScreenSaver -> IO ()
 forceScreenSaver c mode
   = do let req = MkForceScreenSaver mode
        let chunk = runPut (serialize req)
@@ -904,7 +904,7 @@
  
 setPointerMapping ::
                     Graphics.XHB.Connection.Types.Connection ->
-                      Word8 -> [Word8] -> IO (Receipt Word8)
+                      Word8 -> [Word8] -> IO (Receipt MappingStatus)
 setPointerMapping c map_len map
   = do (receipt, rReceipt) <- newEmptyReceipt
                                 (runGet (status_SetPointerMappingReply `fmap` deserialize))
@@ -925,7 +925,7 @@
  
 setModifierMapping ::
                      Graphics.XHB.Connection.Types.Connection ->
-                       Word8 -> [KEYCODE] -> IO (Receipt Word8)
+                       Word8 -> [KEYCODE] -> IO (Receipt MappingStatus)
 setModifierMapping c keycodes_per_modifier keycodes
   = do (receipt, rReceipt) <- newEmptyReceipt
                                 (runGet (status_SetModifierMappingReply `fmap` deserialize))
diff --git a/patched/Graphics/XHB/Gen/Xproto/Types.hs b/patched/Graphics/XHB/Gen/Xproto/Types.hs
--- a/patched/Graphics/XHB/Gen/Xproto/Types.hs
+++ b/patched/Graphics/XHB/Gen/Xproto/Types.hs
@@ -362,6 +362,7 @@
                  | VisualClassPseudoColor
                  | VisualClassTrueColor
                  | VisualClassDirectColor
+                 deriving Show
  
 instance SimpleEnum VisualClass where
         toValue VisualClassStaticGray{} = 0
@@ -378,7 +379,8 @@
         fromValue 5 = VisualClassDirectColor
  
 data VISUALTYPE = MkVISUALTYPE{visual_id_VISUALTYPE :: VISUALID,
-                               class_VISUALTYPE :: Word8, bits_per_rgb_value_VISUALTYPE :: Word8,
+                               class_VISUALTYPE :: VisualClass,
+                               bits_per_rgb_value_VISUALTYPE :: Word8,
                                colormap_entries_VISUALTYPE :: Word16,
                                red_mask_VISUALTYPE :: Word32, green_mask_VISUALTYPE :: Word32,
                                blue_mask_VISUALTYPE :: Word32}
@@ -387,7 +389,7 @@
 instance Serialize VISUALTYPE where
         serialize x
           = do serialize (visual_id_VISUALTYPE x)
-               serialize (class_VISUALTYPE x)
+               serialize (toValue (class_VISUALTYPE x) :: Word8)
                serialize (bits_per_rgb_value_VISUALTYPE x)
                serialize (colormap_entries_VISUALTYPE x)
                serialize (red_mask_VISUALTYPE x)
@@ -395,7 +397,7 @@
                serialize (blue_mask_VISUALTYPE x)
                putSkip 4
         size x
-          = size (visual_id_VISUALTYPE x) + size (class_VISUALTYPE x) +
+          = size (visual_id_VISUALTYPE x) + size (undefined :: Word8) +
               size (bits_per_rgb_value_VISUALTYPE x)
               + size (colormap_entries_VISUALTYPE x)
               + size (red_mask_VISUALTYPE x)
@@ -406,7 +408,7 @@
 instance Deserialize VISUALTYPE where
         deserialize
           = do visual_id <- deserialize
-               class_ <- deserialize
+               class_ <- liftM fromValue (deserialize :: Get Word8)
                bits_per_rgb_value <- deserialize
                colormap_entries <- deserialize
                red_mask <- deserialize
@@ -445,16 +447,17 @@
  
 data SCREEN = MkSCREEN{root_SCREEN :: WINDOW,
                        default_colormap_SCREEN :: COLORMAP, white_pixel_SCREEN :: Word32,
-                       black_pixel_SCREEN :: Word32, current_input_masks_SCREEN :: Word32,
+                       black_pixel_SCREEN :: Word32,
+                       current_input_masks_SCREEN :: [EventMask],
                        width_in_pixels_SCREEN :: Word16,
                        height_in_pixels_SCREEN :: Word16,
                        width_in_millimeters_SCREEN :: Word16,
                        height_in_millimeters_SCREEN :: Word16,
                        min_installed_maps_SCREEN :: Word16,
                        max_installed_maps_SCREEN :: Word16,
-                       root_visual_SCREEN :: VISUALID, backing_stores_SCREEN :: Word8,
-                       save_unders_SCREEN :: Bool, root_depth_SCREEN :: Word8,
-                       allowed_depths_len_SCREEN :: Word8,
+                       root_visual_SCREEN :: VISUALID,
+                       backing_stores_SCREEN :: BackingStore, save_unders_SCREEN :: Bool,
+                       root_depth_SCREEN :: Word8, allowed_depths_len_SCREEN :: Word8,
                        allowed_depths_SCREEN :: [DEPTH]}
             deriving (Show, Typeable)
  
@@ -464,7 +467,7 @@
                serialize (default_colormap_SCREEN x)
                serialize (white_pixel_SCREEN x)
                serialize (black_pixel_SCREEN x)
-               serialize (current_input_masks_SCREEN x)
+               serialize (toMask (current_input_masks_SCREEN x) :: Word32)
                serialize (width_in_pixels_SCREEN x)
                serialize (height_in_pixels_SCREEN x)
                serialize (width_in_millimeters_SCREEN x)
@@ -472,7 +475,7 @@
                serialize (min_installed_maps_SCREEN x)
                serialize (max_installed_maps_SCREEN x)
                serialize (root_visual_SCREEN x)
-               serialize (backing_stores_SCREEN x)
+               serialize (toValue (backing_stores_SCREEN x) :: Word8)
                serialize (save_unders_SCREEN x)
                serialize (root_depth_SCREEN x)
                serialize (allowed_depths_len_SCREEN x)
@@ -481,7 +484,7 @@
           = size (root_SCREEN x) + size (default_colormap_SCREEN x) +
               size (white_pixel_SCREEN x)
               + size (black_pixel_SCREEN x)
-              + size (current_input_masks_SCREEN x)
+              + size (undefined :: Word32)
               + size (width_in_pixels_SCREEN x)
               + size (height_in_pixels_SCREEN x)
               + size (width_in_millimeters_SCREEN x)
@@ -489,7 +492,7 @@
               + size (min_installed_maps_SCREEN x)
               + size (max_installed_maps_SCREEN x)
               + size (root_visual_SCREEN x)
-              + size (backing_stores_SCREEN x)
+              + size (undefined :: Word8)
               + size (save_unders_SCREEN x)
               + size (root_depth_SCREEN x)
               + size (allowed_depths_len_SCREEN x)
@@ -501,7 +504,7 @@
                default_colormap <- deserialize
                white_pixel <- deserialize
                black_pixel <- deserialize
-               current_input_masks <- deserialize
+               current_input_masks <- liftM fromMask (deserialize :: Get Word32)
                width_in_pixels <- deserialize
                height_in_pixels <- deserialize
                width_in_millimeters <- deserialize
@@ -509,7 +512,7 @@
                min_installed_maps <- deserialize
                max_installed_maps <- deserialize
                root_visual <- deserialize
-               backing_stores <- deserialize
+               backing_stores <- liftM fromValue (deserialize :: Get Word8)
                save_unders <- deserialize
                root_depth <- deserialize
                allowed_depths_len <- deserialize
@@ -646,6 +649,7 @@
  
 data ImageOrder = ImageOrderLSBFirst
                 | ImageOrderMSBFirst
+                deriving Show
  
 instance SimpleEnum ImageOrder where
         toValue ImageOrderLSBFirst{} = 0
@@ -660,8 +664,9 @@
                      resource_id_mask_Setup :: Word32,
                      motion_buffer_size_Setup :: Word32, vendor_len_Setup :: Word16,
                      maximum_request_length_Setup :: Word16, roots_len_Setup :: Word8,
-                     pixmap_formats_len_Setup :: Word8, image_byte_order_Setup :: Word8,
-                     bitmap_format_bit_order_Setup :: Word8,
+                     pixmap_formats_len_Setup :: Word8,
+                     image_byte_order_Setup :: ImageOrder,
+                     bitmap_format_bit_order_Setup :: ImageOrder,
                      bitmap_format_scanline_unit_Setup :: Word8,
                      bitmap_format_scanline_pad_Setup :: Word8,
                      min_keycode_Setup :: KEYCODE, max_keycode_Setup :: KEYCODE,
@@ -684,8 +689,8 @@
                serialize (maximum_request_length_Setup x)
                serialize (roots_len_Setup x)
                serialize (pixmap_formats_len_Setup x)
-               serialize (image_byte_order_Setup x)
-               serialize (bitmap_format_bit_order_Setup x)
+               serialize (toValue (image_byte_order_Setup x) :: Word8)
+               serialize (toValue (bitmap_format_bit_order_Setup x) :: Word8)
                serialize (bitmap_format_scanline_unit_Setup x)
                serialize (bitmap_format_scanline_pad_Setup x)
                serialize (min_keycode_Setup x)
@@ -706,8 +711,8 @@
               + size (maximum_request_length_Setup x)
               + size (roots_len_Setup x)
               + size (pixmap_formats_len_Setup x)
-              + size (image_byte_order_Setup x)
-              + size (bitmap_format_bit_order_Setup x)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
               + size (bitmap_format_scanline_unit_Setup x)
               + size (bitmap_format_scanline_pad_Setup x)
               + size (min_keycode_Setup x)
@@ -732,8 +737,9 @@
                maximum_request_length <- deserialize
                roots_len <- deserialize
                pixmap_formats_len <- deserialize
-               image_byte_order <- deserialize
-               bitmap_format_bit_order <- deserialize
+               image_byte_order <- liftM fromValue (deserialize :: Get Word8)
+               bitmap_format_bit_order <- liftM fromValue
+                                            (deserialize :: Get Word8)
                bitmap_format_scanline_unit <- deserialize
                bitmap_format_scanline_pad <- deserialize
                min_keycode <- deserialize
@@ -771,6 +777,7 @@
              | ModMask3
              | ModMask4
              | ModMask5
+             deriving Show
  
 instance BitEnum ModMask where
         toBit ModMaskShift{} = 0
@@ -860,6 +867,7 @@
                 | ButtonMask4
                 | ButtonMask5
                 | ButtonMaskAny
+                deriving Show
  
 instance BitEnum ButtonMask where
         toBit ButtonMask1{} = 8
@@ -943,6 +951,7 @@
  
 data Motion = MotionNormal
             | MotionHint
+            deriving Show
  
 instance SimpleEnum Motion where
         toValue MotionNormal{} = 0
@@ -950,7 +959,7 @@
         fromValue 0 = MotionNormal
         fromValue 1 = MotionHint
  
-data MotionNotify = MkMotionNotify{detail_MotionNotify :: Word8,
+data MotionNotify = MkMotionNotify{detail_MotionNotify :: Motion,
                                    time_MotionNotify :: TIMESTAMP, root_MotionNotify :: WINDOW,
                                    event_MotionNotify :: WINDOW, child_MotionNotify :: WINDOW,
                                    root_x_MotionNotify :: Int16, root_y_MotionNotify :: Int16,
@@ -963,7 +972,7 @@
 instance Deserialize MotionNotify where
         deserialize
           = do skip 1
-               detail <- deserialize
+               detail <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                time <- deserialize
                root <- deserialize
@@ -990,6 +999,7 @@
                   | NotifyDetailPointer
                   | NotifyDetailPointerRoot
                   | NotifyDetailNone
+                  deriving Show
  
 instance SimpleEnum NotifyDetail where
         toValue NotifyDetailAncestor{} = 0
@@ -1013,6 +1023,7 @@
                 | NotifyModeGrab
                 | NotifyModeUngrab
                 | NotifyModeWhileGrabbed
+                deriving Show
  
 instance SimpleEnum NotifyMode where
         toValue NotifyModeNormal{} = 0
@@ -1024,12 +1035,13 @@
         fromValue 2 = NotifyModeUngrab
         fromValue 3 = NotifyModeWhileGrabbed
  
-data EnterNotify = MkEnterNotify{detail_EnterNotify :: Word8,
+data EnterNotify = MkEnterNotify{detail_EnterNotify ::
+                                 NotifyDetail,
                                  time_EnterNotify :: TIMESTAMP, root_EnterNotify :: WINDOW,
                                  event_EnterNotify :: WINDOW, child_EnterNotify :: WINDOW,
                                  root_x_EnterNotify :: Int16, root_y_EnterNotify :: Int16,
                                  event_x_EnterNotify :: Int16, event_y_EnterNotify :: Int16,
-                                 state_EnterNotify :: Word16, mode_EnterNotify :: Word8,
+                                 state_EnterNotify :: Word16, mode_EnterNotify :: NotifyMode,
                                  same_screen_focus_EnterNotify :: Word8}
                  deriving (Show, Typeable)
  
@@ -1038,7 +1050,7 @@
 instance Deserialize EnterNotify where
         deserialize
           = do skip 1
-               detail <- deserialize
+               detail <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                time <- deserialize
                root <- deserialize
@@ -1049,7 +1061,7 @@
                event_x <- deserialize
                event_y <- deserialize
                state <- deserialize
-               mode <- deserialize
+               mode <- liftM fromValue (deserialize :: Get Word8)
                same_screen_focus <- deserialize
                return
                  (MkEnterNotify detail time root event child root_x root_y event_x
@@ -1058,12 +1070,13 @@
                     mode
                     same_screen_focus)
  
-data LeaveNotify = MkLeaveNotify{detail_LeaveNotify :: Word8,
+data LeaveNotify = MkLeaveNotify{detail_LeaveNotify ::
+                                 NotifyDetail,
                                  time_LeaveNotify :: TIMESTAMP, root_LeaveNotify :: WINDOW,
                                  event_LeaveNotify :: WINDOW, child_LeaveNotify :: WINDOW,
                                  root_x_LeaveNotify :: Int16, root_y_LeaveNotify :: Int16,
                                  event_x_LeaveNotify :: Int16, event_y_LeaveNotify :: Int16,
-                                 state_LeaveNotify :: Word16, mode_LeaveNotify :: Word8,
+                                 state_LeaveNotify :: Word16, mode_LeaveNotify :: NotifyMode,
                                  same_screen_focus_LeaveNotify :: Word8}
                  deriving (Show, Typeable)
  
@@ -1072,7 +1085,7 @@
 instance Deserialize LeaveNotify where
         deserialize
           = do skip 1
-               detail <- deserialize
+               detail <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                time <- deserialize
                root <- deserialize
@@ -1083,7 +1096,7 @@
                event_x <- deserialize
                event_y <- deserialize
                state <- deserialize
-               mode <- deserialize
+               mode <- liftM fromValue (deserialize :: Get Word8)
                same_screen_focus <- deserialize
                return
                  (MkLeaveNotify detail time root event child root_x root_y event_x
@@ -1092,8 +1105,8 @@
                     mode
                     same_screen_focus)
  
-data FocusIn = MkFocusIn{detail_FocusIn :: Word8,
-                         event_FocusIn :: WINDOW, mode_FocusIn :: Word8}
+data FocusIn = MkFocusIn{detail_FocusIn :: NotifyDetail,
+                         event_FocusIn :: WINDOW, mode_FocusIn :: NotifyMode}
              deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event FocusIn
@@ -1101,15 +1114,15 @@
 instance Deserialize FocusIn where
         deserialize
           = do skip 1
-               detail <- deserialize
+               detail <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                event <- deserialize
-               mode <- deserialize
+               mode <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkFocusIn detail event mode)
  
-data FocusOut = MkFocusOut{detail_FocusOut :: Word8,
-                           event_FocusOut :: WINDOW, mode_FocusOut :: Word8}
+data FocusOut = MkFocusOut{detail_FocusOut :: NotifyDetail,
+                           event_FocusOut :: WINDOW, mode_FocusOut :: NotifyMode}
               deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event FocusOut
@@ -1117,10 +1130,10 @@
 instance Deserialize FocusOut where
         deserialize
           = do skip 1
-               detail <- deserialize
+               detail <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                event <- deserialize
-               mode <- deserialize
+               mode <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkFocusOut detail event mode)
  
@@ -1208,6 +1221,7 @@
 data Visibility = VisibilityUnobscured
                 | VisibilityPartiallyObscured
                 | VisibilityFullyObscured
+                deriving Show
  
 instance SimpleEnum Visibility where
         toValue VisibilityUnobscured{} = 0
@@ -1219,7 +1233,7 @@
  
 data VisibilityNotify = MkVisibilityNotify{window_VisibilityNotify
                                            :: WINDOW,
-                                           state_VisibilityNotify :: Word8}
+                                           state_VisibilityNotify :: Visibility}
                       deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event VisibilityNotify
@@ -1230,7 +1244,7 @@
                skip 1
                skip 2
                window <- deserialize
-               state <- deserialize
+               state <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkVisibilityNotify window state)
  
@@ -1429,7 +1443,7 @@
                     override_redirect)
  
 data ConfigureRequest = MkConfigureRequest{stack_mode_ConfigureRequest
-                                           :: Word8,
+                                           :: StackMode,
                                            parent_ConfigureRequest :: WINDOW,
                                            window_ConfigureRequest :: WINDOW,
                                            sibling_ConfigureRequest :: WINDOW,
@@ -1437,7 +1451,7 @@
                                            width_ConfigureRequest :: Word16,
                                            height_ConfigureRequest :: Word16,
                                            border_width_ConfigureRequest :: Word16,
-                                           value_mask_ConfigureRequest :: Word16}
+                                           value_mask_ConfigureRequest :: [ConfigWindow]}
                       deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event ConfigureRequest
@@ -1445,7 +1459,7 @@
 instance Deserialize ConfigureRequest where
         deserialize
           = do skip 1
-               stack_mode <- deserialize
+               stack_mode <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                parent <- deserialize
                window <- deserialize
@@ -1455,7 +1469,7 @@
                width <- deserialize
                height <- deserialize
                border_width <- deserialize
-               value_mask <- deserialize
+               value_mask <- liftM fromMask (deserialize :: Get Word16)
                return
                  (MkConfigureRequest stack_mode parent window sibling x y width
                     height
@@ -1499,6 +1513,7 @@
  
 data Place = PlaceOnTop
            | PlaceOnBottom
+           deriving Show
  
 instance SimpleEnum Place where
         toValue PlaceOnTop{} = 0
@@ -1509,7 +1524,7 @@
 data CirculateNotify = MkCirculateNotify{event_CirculateNotify ::
                                          WINDOW,
                                          window_CirculateNotify :: WINDOW,
-                                         place_CirculateNotify :: Word8}
+                                         place_CirculateNotify :: Place}
                      deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event CirculateNotify
@@ -1522,14 +1537,14 @@
                event <- deserialize
                window <- deserialize
                skip 4
-               place <- deserialize
+               place <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkCirculateNotify event window place)
  
 data CirculateRequest = MkCirculateRequest{event_CirculateRequest
                                            :: WINDOW,
                                            window_CirculateRequest :: WINDOW,
-                                           place_CirculateRequest :: Word8}
+                                           place_CirculateRequest :: Place}
                       deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event CirculateRequest
@@ -1542,12 +1557,13 @@
                event <- deserialize
                window <- deserialize
                skip 4
-               place <- deserialize
+               place <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkCirculateRequest event window place)
  
 data Property = PropertyNewValue
               | PropertyDelete
+              deriving Show
  
 instance SimpleEnum Property where
         toValue PropertyNewValue{} = 0
@@ -1559,7 +1575,7 @@
                                        WINDOW,
                                        atom_PropertyNotify :: ATOM,
                                        time_PropertyNotify :: TIMESTAMP,
-                                       state_PropertyNotify :: Word8}
+                                       state_PropertyNotify :: Property}
                     deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event PropertyNotify
@@ -1572,7 +1588,7 @@
                window <- deserialize
                atom <- deserialize
                time <- deserialize
-               state <- deserialize
+               state <- liftM fromValue (deserialize :: Get Word8)
                skip 3
                return (MkPropertyNotify window atom time state)
  
@@ -1643,6 +1659,7 @@
  
 data ColormapState = ColormapStateUninstalled
                    | ColormapStateInstalled
+                   deriving Show
  
 instance SimpleEnum ColormapState where
         toValue ColormapStateUninstalled{} = 0
@@ -1653,7 +1670,8 @@
 data ColormapNotify = MkColormapNotify{window_ColormapNotify ::
                                        WINDOW,
                                        colormap_ColormapNotify :: COLORMAP,
-                                       new_ColormapNotify :: Bool, state_ColormapNotify :: Word8}
+                                       new_ColormapNotify :: Bool,
+                                       state_ColormapNotify :: ColormapState}
                     deriving (Show, Typeable)
  
 instance Graphics.XHB.Shared.Event ColormapNotify
@@ -1666,7 +1684,7 @@
                window <- deserialize
                colormap <- deserialize
                new <- deserialize
-               state <- deserialize
+               state <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                return (MkColormapNotify window colormap new state)
  
@@ -1690,6 +1708,7 @@
 data Mapping = MappingModifier
              | MappingKeyboard
              | MappingPointer
+             deriving Show
  
 instance SimpleEnum Mapping where
         toValue MappingModifier{} = 0
@@ -1700,7 +1719,7 @@
         fromValue 2 = MappingPointer
  
 data MappingNotify = MkMappingNotify{request_MappingNotify ::
-                                     Word8,
+                                     Mapping,
                                      first_keycode_MappingNotify :: KEYCODE,
                                      count_MappingNotify :: Word8}
                    deriving (Show, Typeable)
@@ -1712,7 +1731,7 @@
           = do skip 1
                skip 1
                skip 2
-               request <- deserialize
+               request <- liftM fromValue (deserialize :: Get Word8)
                first_keycode <- deserialize
                count <- deserialize
                skip 1
@@ -1978,6 +1997,7 @@
 data WindowClass = WindowClassCopyFromParent
                  | WindowClassInputOutput
                  | WindowClassInputOnly
+                 deriving Show
  
 instance SimpleEnum WindowClass where
         toValue WindowClassCopyFromParent{} = 0
@@ -2002,6 +2022,7 @@
         | CWDontPropagate
         | CWColormap
         | CWCursor
+        deriving Show
  
 instance BitEnum CW where
         toBit CWBackPixmap{} = 0
@@ -2037,6 +2058,7 @@
  
 data BackPixmap = BackPixmapNone
                 | BackPixmapParentRelative
+                deriving Show
  
 instance SimpleEnum BackPixmap where
         toValue BackPixmapNone{} = 0
@@ -2056,6 +2078,7 @@
              | GravitySouth
              | GravitySouthEast
              | GravityStatic
+             deriving Show
  
 instance SimpleEnum Gravity where
         toValue GravityBitForget{} = 0
@@ -2086,6 +2109,7 @@
 data BackingStore = BackingStoreNotUseful
                   | BackingStoreWhenMapped
                   | BackingStoreAlways
+                  deriving Show
  
 instance SimpleEnum BackingStore where
         toValue BackingStoreNotUseful{} = 0
@@ -2120,6 +2144,7 @@
                | EventMaskPropertyChange
                | EventMaskColorMapChange
                | EventMaskOwnerGrabButton
+               deriving Show
  
 instance BitEnum EventMask where
         toBit EventMaskKeyPress{} = 0
@@ -2178,7 +2203,8 @@
                                    x_CreateWindow :: Int16, y_CreateWindow :: Int16,
                                    width_CreateWindow :: Word16, height_CreateWindow :: Word16,
                                    border_width_CreateWindow :: Word16,
-                                   class_CreateWindow :: Word16, visual_CreateWindow :: VISUALID,
+                                   class_CreateWindow :: WindowClass,
+                                   visual_CreateWindow :: VISUALID,
                                    value_CreateWindow :: ValueParam Word32}
                   deriving (Show, Typeable)
  
@@ -2194,7 +2220,7 @@
                serialize (width_CreateWindow x)
                serialize (height_CreateWindow x)
                serialize (border_width_CreateWindow x)
-               serialize (class_CreateWindow x)
+               serialize (toValue (class_CreateWindow x) :: Word16)
                serialize (visual_CreateWindow x)
                serialize (value_CreateWindow x)
                putSkip (requiredPadding (size x))
@@ -2206,7 +2232,7 @@
               + size (width_CreateWindow x)
               + size (height_CreateWindow x)
               + size (border_width_CreateWindow x)
-              + size (class_CreateWindow x)
+              + size (undefined :: Word16)
               + size (visual_CreateWindow x)
               + size (value_CreateWindow x)
  
@@ -2231,6 +2257,7 @@
 data MapState = MapStateUnmapped
               | MapStateUnviewable
               | MapStateViewable
+              deriving Show
  
 instance SimpleEnum MapState where
         toValue MapStateUnmapped{} = 0
@@ -2254,14 +2281,15 @@
         size x = 3 + 1 + size (window_GetWindowAttributes x)
  
 data GetWindowAttributesReply = MkGetWindowAttributesReply{backing_store_GetWindowAttributesReply
-                                                           :: Word8,
+                                                           :: BackingStore,
                                                            visual_GetWindowAttributesReply ::
                                                            VISUALID,
-                                                           class_GetWindowAttributesReply :: Word16,
+                                                           class_GetWindowAttributesReply ::
+                                                           WindowClass,
                                                            bit_gravity_GetWindowAttributesReply ::
-                                                           Word8,
+                                                           Gravity,
                                                            win_gravity_GetWindowAttributesReply ::
-                                                           Word8,
+                                                           Gravity,
                                                            backing_planes_GetWindowAttributesReply
                                                            :: Word32,
                                                            backing_pixel_GetWindowAttributesReply ::
@@ -2271,39 +2299,39 @@
                                                            map_is_installed_GetWindowAttributesReply
                                                            :: Bool,
                                                            map_state_GetWindowAttributesReply ::
-                                                           Word8,
+                                                           MapState,
                                                            override_redirect_GetWindowAttributesReply
                                                            :: Bool,
                                                            colormap_GetWindowAttributesReply ::
                                                            COLORMAP,
                                                            all_event_masks_GetWindowAttributesReply
-                                                           :: Word32,
+                                                           :: [EventMask],
                                                            your_event_mask_GetWindowAttributesReply
-                                                           :: Word32,
+                                                           :: [EventMask],
                                                            do_not_propagate_mask_GetWindowAttributesReply
-                                                           :: Word16}
+                                                           :: [EventMask]}
                               deriving (Show, Typeable)
  
 instance Deserialize GetWindowAttributesReply where
         deserialize
           = do skip 1
-               backing_store <- deserialize
+               backing_store <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                visual <- deserialize
-               class_ <- deserialize
-               bit_gravity <- deserialize
-               win_gravity <- deserialize
+               class_ <- liftM fromValue (deserialize :: Get Word16)
+               bit_gravity <- liftM fromValue (deserialize :: Get Word8)
+               win_gravity <- liftM fromValue (deserialize :: Get Word8)
                backing_planes <- deserialize
                backing_pixel <- deserialize
                save_under <- deserialize
                map_is_installed <- deserialize
-               map_state <- deserialize
+               map_state <- liftM fromValue (deserialize :: Get Word8)
                override_redirect <- deserialize
                colormap <- deserialize
-               all_event_masks <- deserialize
-               your_event_mask <- deserialize
-               do_not_propagate_mask <- deserialize
+               all_event_masks <- liftM fromMask (deserialize :: Get Word32)
+               your_event_mask <- liftM fromMask (deserialize :: Get Word32)
+               do_not_propagate_mask <- liftM fromMask (deserialize :: Get Word16)
                skip 2
                let _ = isCard32 length
                return
@@ -2348,6 +2376,7 @@
  
 data SetMode = SetModeInsert
              | SetModeDelete
+             deriving Show
  
 instance SimpleEnum SetMode where
         toValue SetModeInsert{} = 0
@@ -2355,19 +2384,19 @@
         fromValue 0 = SetModeInsert
         fromValue 1 = SetModeDelete
  
-data ChangeSaveSet = MkChangeSaveSet{mode_ChangeSaveSet :: Word8,
+data ChangeSaveSet = MkChangeSaveSet{mode_ChangeSaveSet :: SetMode,
                                      window_ChangeSaveSet :: WINDOW}
                    deriving (Show, Typeable)
  
 instance Serialize ChangeSaveSet where
         serialize x
           = do putWord8 6
-               serialize (mode_ChangeSaveSet x)
+               serialize (toValue (mode_ChangeSaveSet x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (window_ChangeSaveSet x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (mode_ChangeSaveSet x) + size (window_ChangeSaveSet x)
+          = 3 + size (undefined :: Word8) + size (window_ChangeSaveSet x)
  
 data ReparentWindow = MkReparentWindow{window_ReparentWindow ::
                                        WINDOW,
@@ -2448,6 +2477,7 @@
                   | ConfigWindowBorderWidth
                   | ConfigWindowSibling
                   | ConfigWindowStackMode
+                  deriving Show
  
 instance BitEnum ConfigWindow where
         toBit ConfigWindowX{} = 0
@@ -2470,6 +2500,7 @@
                | StackModeTopIf
                | StackModeBottomIf
                | StackModeOpposite
+               deriving Show
  
 instance SimpleEnum StackMode where
         toValue StackModeAbove{} = 0
@@ -2498,11 +2529,11 @@
                putSkip (requiredPadding (size x))
         size x
           = 3 + 1 + size (window_ConfigureWindow x) +
-              size (value_ConfigureWindow x)
-              + 2
+              (size (value_ConfigureWindow x) + 2)
  
 data Circulate = CirculateRaiseLowest
                | CirculateLowerHighest
+               deriving Show
  
 instance SimpleEnum Circulate where
         toValue CirculateRaiseLowest{} = 0
@@ -2511,20 +2542,19 @@
         fromValue 1 = CirculateLowerHighest
  
 data CirculateWindow = MkCirculateWindow{direction_CirculateWindow
-                                         :: Word8,
+                                         :: Circulate,
                                          window_CirculateWindow :: WINDOW}
                      deriving (Show, Typeable)
  
 instance Serialize CirculateWindow where
         serialize x
           = do putWord8 13
-               serialize (direction_CirculateWindow x)
+               serialize (toValue (direction_CirculateWindow x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (window_CirculateWindow x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (direction_CirculateWindow x) +
-              size (window_CirculateWindow x)
+          = 3 + size (undefined :: Word8) + size (window_CirculateWindow x)
  
 data GetGeometry = MkGetGeometry{drawable_GetGeometry :: DRAWABLE}
                  deriving (Show, Typeable)
@@ -2662,6 +2692,7 @@
 data PropMode = PropModeReplace
               | PropModePrepend
               | PropModeAppend
+              deriving Show
  
 instance SimpleEnum PropMode where
         toValue PropModeReplace{} = 0
@@ -2672,7 +2703,7 @@
         fromValue 2 = PropModeAppend
  
 data ChangeProperty = MkChangeProperty{mode_ChangeProperty ::
-                                       Word8,
+                                       PropMode,
                                        window_ChangeProperty :: WINDOW,
                                        property_ChangeProperty :: ATOM, type_ChangeProperty :: ATOM,
                                        format_ChangeProperty :: Word8,
@@ -2683,7 +2714,7 @@
 instance Serialize ChangeProperty where
         serialize x
           = do putWord8 18
-               serialize (mode_ChangeProperty x)
+               serialize (toValue (mode_ChangeProperty x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (window_ChangeProperty x)
                serialize (property_ChangeProperty x)
@@ -2694,8 +2725,8 @@
                serializeList (data_ChangeProperty x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (mode_ChangeProperty x) + size (window_ChangeProperty x)
-              + size (property_ChangeProperty x)
+          = 3 + size (undefined :: Word8) + size (window_ChangeProperty x) +
+              size (property_ChangeProperty x)
               + size (type_ChangeProperty x)
               + size (format_ChangeProperty x)
               + 3
@@ -2720,6 +2751,7 @@
               size (property_DeleteProperty x)
  
 data GetPropertyType = GetPropertyTypeAny
+                     deriving Show
  
 instance SimpleEnum GetPropertyType where
         toValue GetPropertyTypeAny{} = 0
@@ -2727,7 +2759,8 @@
  
 data GetProperty = MkGetProperty{delete_GetProperty :: Bool,
                                  window_GetProperty :: WINDOW, property_GetProperty :: ATOM,
-                                 type_GetProperty :: ATOM, long_offset_GetProperty :: Word32,
+                                 type_GetProperty :: ATOM,
+                                 long_offset_GetProperty :: Word32,
                                  long_length_GetProperty :: Word32}
                  deriving (Show, Typeable)
  
@@ -2745,7 +2778,7 @@
         size x
           = 3 + size (delete_GetProperty x) + size (window_GetProperty x) +
               size (property_GetProperty x)
-              + size (type_GetProperty x)
+              + size (undefined :: ATOM)
               + size (long_offset_GetProperty x)
               + size (long_length_GetProperty x)
  
@@ -2877,6 +2910,7 @@
  
 data SendEventDest = SendEventDestPointerWindow
                    | SendEventDestItemFocus
+                   deriving Show
  
 instance SimpleEnum SendEventDest where
         toValue SendEventDestPointerWindow{} = 0
@@ -2885,8 +2919,8 @@
         fromValue 1 = SendEventDestItemFocus
  
 data SendEvent = MkSendEvent{propagate_SendEvent :: Bool,
-                             destination_SendEvent :: WINDOW, event_mask_SendEvent :: Word32,
-                             event_SendEvent :: [CChar]}
+                             destination_SendEvent :: WINDOW,
+                             event_mask_SendEvent :: [EventMask], event_SendEvent :: [CChar]}
                deriving (Show, Typeable)
  
 instance Serialize SendEvent where
@@ -2895,16 +2929,17 @@
                serialize (propagate_SendEvent x)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (destination_SendEvent x)
-               serialize (event_mask_SendEvent x)
+               serialize (toMask (event_mask_SendEvent x) :: Word32)
                serializeList (event_SendEvent x)
                putSkip (requiredPadding (size x))
         size x
           = 3 + size (propagate_SendEvent x) + size (destination_SendEvent x)
-              + size (event_mask_SendEvent x)
+              + size (undefined :: Word32)
               + sum (map size (event_SendEvent x))
  
 data GrabMode = GrabModeSync
               | GrabModeAsync
+              deriving Show
  
 instance SimpleEnum GrabMode where
         toValue GrabModeSync{} = 0
@@ -2917,6 +2952,7 @@
                 | GrabStatusInvalidTime
                 | GrabStatusNotViewable
                 | GrabStatusFrozen
+                deriving Show
  
 instance SimpleEnum GrabStatus where
         toValue GrabStatusSuccess{} = 0
@@ -2932,9 +2968,9 @@
  
 data GrabPointer = MkGrabPointer{owner_events_GrabPointer :: Bool,
                                  grab_window_GrabPointer :: WINDOW,
-                                 event_mask_GrabPointer :: Word16,
-                                 pointer_mode_GrabPointer :: Word8,
-                                 keyboard_mode_GrabPointer :: Word8,
+                                 event_mask_GrabPointer :: [EventMask],
+                                 pointer_mode_GrabPointer :: GrabMode,
+                                 keyboard_mode_GrabPointer :: GrabMode,
                                  confine_to_GrabPointer :: WINDOW, cursor_GrabPointer :: CURSOR,
                                  time_GrabPointer :: TIMESTAMP}
                  deriving (Show, Typeable)
@@ -2945,9 +2981,9 @@
                serialize (owner_events_GrabPointer x)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_GrabPointer x)
-               serialize (event_mask_GrabPointer x)
-               serialize (pointer_mode_GrabPointer x)
-               serialize (keyboard_mode_GrabPointer x)
+               serialize (toMask (event_mask_GrabPointer x) :: Word16)
+               serialize (toValue (pointer_mode_GrabPointer x) :: Word8)
+               serialize (toValue (keyboard_mode_GrabPointer x) :: Word8)
                serialize (confine_to_GrabPointer x)
                serialize (cursor_GrabPointer x)
                serialize (time_GrabPointer x)
@@ -2955,21 +2991,21 @@
         size x
           = 3 + size (owner_events_GrabPointer x) +
               size (grab_window_GrabPointer x)
-              + size (event_mask_GrabPointer x)
-              + size (pointer_mode_GrabPointer x)
-              + size (keyboard_mode_GrabPointer x)
+              + size (undefined :: Word16)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
               + size (confine_to_GrabPointer x)
               + size (cursor_GrabPointer x)
               + size (time_GrabPointer x)
  
 data GrabPointerReply = MkGrabPointerReply{status_GrabPointerReply
-                                           :: Word8}
+                                           :: GrabStatus}
                       deriving (Show, Typeable)
  
 instance Deserialize GrabPointerReply where
         deserialize
           = do skip 1
-               status <- deserialize
+               status <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                let _ = isCard32 length
@@ -2994,6 +3030,7 @@
                  | ButtonIndex3
                  | ButtonIndex4
                  | ButtonIndex5
+                 deriving Show
  
 instance SimpleEnum ButtonIndex where
         toValue ButtonIndexAny{} = 0
@@ -3010,11 +3047,13 @@
         fromValue 5 = ButtonIndex5
  
 data GrabButton = MkGrabButton{owner_events_GrabButton :: Bool,
-                               grab_window_GrabButton :: WINDOW, event_mask_GrabButton :: Word16,
-                               pointer_mode_GrabButton :: Word8,
-                               keyboard_mode_GrabButton :: Word8, confine_to_GrabButton :: WINDOW,
-                               cursor_GrabButton :: CURSOR, button_GrabButton :: Word8,
-                               modifiers_GrabButton :: Word16}
+                               grab_window_GrabButton :: WINDOW,
+                               event_mask_GrabButton :: [EventMask],
+                               pointer_mode_GrabButton :: GrabMode,
+                               keyboard_mode_GrabButton :: GrabMode,
+                               confine_to_GrabButton :: WINDOW, cursor_GrabButton :: CURSOR,
+                               button_GrabButton :: ButtonIndex,
+                               modifiers_GrabButton :: [ModMask]}
                 deriving (Show, Typeable)
  
 instance Serialize GrabButton where
@@ -3023,52 +3062,52 @@
                serialize (owner_events_GrabButton x)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_GrabButton x)
-               serialize (event_mask_GrabButton x)
-               serialize (pointer_mode_GrabButton x)
-               serialize (keyboard_mode_GrabButton x)
+               serialize (toMask (event_mask_GrabButton x) :: Word16)
+               serialize (toValue (pointer_mode_GrabButton x) :: Word8)
+               serialize (toValue (keyboard_mode_GrabButton x) :: Word8)
                serialize (confine_to_GrabButton x)
                serialize (cursor_GrabButton x)
-               serialize (button_GrabButton x)
+               serialize (toValue (button_GrabButton x) :: Word8)
                putSkip 1
-               serialize (modifiers_GrabButton x)
+               serialize (toMask (modifiers_GrabButton x) :: Word16)
                putSkip (requiredPadding (size x))
         size x
           = 3 + size (owner_events_GrabButton x) +
               size (grab_window_GrabButton x)
-              + size (event_mask_GrabButton x)
-              + size (pointer_mode_GrabButton x)
-              + size (keyboard_mode_GrabButton x)
+              + size (undefined :: Word16)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
               + size (confine_to_GrabButton x)
               + size (cursor_GrabButton x)
-              + size (button_GrabButton x)
+              + size (undefined :: Word8)
               + 1
-              + size (modifiers_GrabButton x)
+              + size (undefined :: Word16)
  
-data UngrabButton = MkUngrabButton{button_UngrabButton :: Word8,
+data UngrabButton = MkUngrabButton{button_UngrabButton ::
+                                   ButtonIndex,
                                    grab_window_UngrabButton :: WINDOW,
-                                   modifiers_UngrabButton :: Word16}
+                                   modifiers_UngrabButton :: [ModMask]}
                   deriving (Show, Typeable)
  
 instance Serialize UngrabButton where
         serialize x
           = do putWord8 29
-               serialize (button_UngrabButton x)
+               serialize (toValue (button_UngrabButton x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_UngrabButton x)
-               serialize (modifiers_UngrabButton x)
+               serialize (toMask (modifiers_UngrabButton x) :: Word16)
                putSkip 2
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (button_UngrabButton x) +
-              size (grab_window_UngrabButton x)
-              + size (modifiers_UngrabButton x)
+          = 3 + size (undefined :: Word8) + size (grab_window_UngrabButton x)
+              + size (undefined :: Word16)
               + 2
  
 data ChangeActivePointerGrab = MkChangeActivePointerGrab{cursor_ChangeActivePointerGrab
                                                          :: CURSOR,
                                                          time_ChangeActivePointerGrab :: TIMESTAMP,
                                                          event_mask_ChangeActivePointerGrab ::
-                                                         Word16}
+                                                         [EventMask]}
                              deriving (Show, Typeable)
  
 instance Serialize ChangeActivePointerGrab where
@@ -3078,21 +3117,21 @@
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (cursor_ChangeActivePointerGrab x)
                serialize (time_ChangeActivePointerGrab x)
-               serialize (event_mask_ChangeActivePointerGrab x)
+               serialize (toMask (event_mask_ChangeActivePointerGrab x) :: Word16)
                putSkip 2
                putSkip (requiredPadding (size x))
         size x
           = 3 + 1 + size (cursor_ChangeActivePointerGrab x) +
               size (time_ChangeActivePointerGrab x)
-              + size (event_mask_ChangeActivePointerGrab x)
+              + size (undefined :: Word16)
               + 2
  
 data GrabKeyboard = MkGrabKeyboard{owner_events_GrabKeyboard ::
                                    Bool,
                                    grab_window_GrabKeyboard :: WINDOW,
                                    time_GrabKeyboard :: TIMESTAMP,
-                                   pointer_mode_GrabKeyboard :: Word8,
-                                   keyboard_mode_GrabKeyboard :: Word8}
+                                   pointer_mode_GrabKeyboard :: GrabMode,
+                                   keyboard_mode_GrabKeyboard :: GrabMode}
                   deriving (Show, Typeable)
  
 instance Serialize GrabKeyboard where
@@ -3102,26 +3141,26 @@
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_GrabKeyboard x)
                serialize (time_GrabKeyboard x)
-               serialize (pointer_mode_GrabKeyboard x)
-               serialize (keyboard_mode_GrabKeyboard x)
+               serialize (toValue (pointer_mode_GrabKeyboard x) :: Word8)
+               serialize (toValue (keyboard_mode_GrabKeyboard x) :: Word8)
                putSkip 2
                putSkip (requiredPadding (size x))
         size x
           = 3 + size (owner_events_GrabKeyboard x) +
               size (grab_window_GrabKeyboard x)
               + size (time_GrabKeyboard x)
-              + size (pointer_mode_GrabKeyboard x)
-              + size (keyboard_mode_GrabKeyboard x)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
               + 2
  
 data GrabKeyboardReply = MkGrabKeyboardReply{status_GrabKeyboardReply
-                                             :: Word8}
+                                             :: GrabStatus}
                        deriving (Show, Typeable)
  
 instance Deserialize GrabKeyboardReply where
         deserialize
           = do skip 1
-               status <- deserialize
+               status <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                let _ = isCard32 length
@@ -3141,15 +3180,16 @@
         size x = 3 + 1 + size (time_UngrabKeyboard x)
  
 data Grab = GrabAny
+          deriving Show
  
 instance SimpleEnum Grab where
         toValue GrabAny{} = 0
         fromValue 0 = GrabAny
  
 data GrabKey = MkGrabKey{owner_events_GrabKey :: Bool,
-                         grab_window_GrabKey :: WINDOW, modifiers_GrabKey :: Word16,
-                         key_GrabKey :: KEYCODE, pointer_mode_GrabKey :: Word8,
-                         keyboard_mode_GrabKey :: Word8}
+                         grab_window_GrabKey :: WINDOW, modifiers_GrabKey :: [ModMask],
+                         key_GrabKey :: KEYCODE, pointer_mode_GrabKey :: GrabMode,
+                         keyboard_mode_GrabKey :: GrabMode}
              deriving (Show, Typeable)
  
 instance Serialize GrabKey where
@@ -3158,22 +3198,22 @@
                serialize (owner_events_GrabKey x)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_GrabKey x)
-               serialize (modifiers_GrabKey x)
+               serialize (toMask (modifiers_GrabKey x) :: Word16)
                serialize (key_GrabKey x)
-               serialize (pointer_mode_GrabKey x)
-               serialize (keyboard_mode_GrabKey x)
+               serialize (toValue (pointer_mode_GrabKey x) :: Word8)
+               serialize (toValue (keyboard_mode_GrabKey x) :: Word8)
                putSkip 3
                putSkip (requiredPadding (size x))
         size x
           = 3 + size (owner_events_GrabKey x) + size (grab_window_GrabKey x)
-              + size (modifiers_GrabKey x)
+              + size (undefined :: Word16)
               + size (key_GrabKey x)
-              + size (pointer_mode_GrabKey x)
-              + size (keyboard_mode_GrabKey x)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
               + 3
  
 data UngrabKey = MkUngrabKey{key_UngrabKey :: KEYCODE,
-                             grab_window_UngrabKey :: WINDOW, modifiers_UngrabKey :: Word16}
+                             grab_window_UngrabKey :: WINDOW, modifiers_UngrabKey :: [ModMask]}
                deriving (Show, Typeable)
  
 instance Serialize UngrabKey where
@@ -3182,12 +3222,12 @@
                serialize (key_UngrabKey x)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (grab_window_UngrabKey x)
-               serialize (modifiers_UngrabKey x)
+               serialize (toMask (modifiers_UngrabKey x) :: Word16)
                putSkip 2
                putSkip (requiredPadding (size x))
         size x
           = 3 + size (key_UngrabKey x) + size (grab_window_UngrabKey x) +
-              size (modifiers_UngrabKey x)
+              size (undefined :: Word16)
               + 2
  
 data Allow = AllowAsyncPointer
@@ -3198,6 +3238,7 @@
            | AllowReplayKeyboard
            | AllowAsyncBoth
            | AllowSyncBoth
+           deriving Show
  
 instance SimpleEnum Allow where
         toValue AllowAsyncPointer{} = 0
@@ -3217,18 +3258,18 @@
         fromValue 6 = AllowAsyncBoth
         fromValue 7 = AllowSyncBoth
  
-data AllowEvents = MkAllowEvents{mode_AllowEvents :: Word8,
+data AllowEvents = MkAllowEvents{mode_AllowEvents :: Allow,
                                  time_AllowEvents :: TIMESTAMP}
                  deriving (Show, Typeable)
  
 instance Serialize AllowEvents where
         serialize x
           = do putWord8 35
-               serialize (mode_AllowEvents x)
+               serialize (toValue (mode_AllowEvents x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (time_AllowEvents x)
                putSkip (requiredPadding (size x))
-        size x = 3 + size (mode_AllowEvents x) + size (time_AllowEvents x)
+        size x = 3 + size (undefined :: Word8) + size (time_AllowEvents x)
  
 data QueryPointer = MkQueryPointer{window_QueryPointer :: WINDOW}
                   deriving (Show, Typeable)
@@ -3409,6 +3450,7 @@
 data InputFocus = InputFocusNone
                 | InputFocusPointerRoot
                 | InputFocusParent
+                deriving Show
  
 instance SimpleEnum InputFocus where
         toValue InputFocusNone{} = 0
@@ -3419,22 +3461,21 @@
         fromValue 2 = InputFocusParent
  
 data SetInputFocus = MkSetInputFocus{revert_to_SetInputFocus ::
-                                     Word8,
+                                     InputFocus,
                                      focus_SetInputFocus :: WINDOW, time_SetInputFocus :: TIMESTAMP}
                    deriving (Show, Typeable)
  
 instance Serialize SetInputFocus where
         serialize x
           = do putWord8 42
-               serialize (revert_to_SetInputFocus x)
+               serialize (toValue (revert_to_SetInputFocus x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (focus_SetInputFocus x)
                serialize (time_SetInputFocus x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (revert_to_SetInputFocus x) +
-              size (focus_SetInputFocus x)
-              + size (time_SetInputFocus x)
+          = 3 + size (undefined :: Word8) + size (focus_SetInputFocus x) +
+              size (time_SetInputFocus x)
  
 data GetInputFocus = MkGetInputFocus{}
                    deriving (Show, Typeable)
@@ -3448,14 +3489,14 @@
         size x = 4
  
 data GetInputFocusReply = MkGetInputFocusReply{revert_to_GetInputFocusReply
-                                               :: Word8,
+                                               :: InputFocus,
                                                focus_GetInputFocusReply :: WINDOW}
                         deriving (Show, Typeable)
  
 instance Deserialize GetInputFocusReply where
         deserialize
           = do skip 1
-               revert_to <- deserialize
+               revert_to <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                focus <- deserialize
@@ -3519,6 +3560,7 @@
  
 data FontDraw = FontDrawLeftToRight
               | FontDrawRightToLeft
+              deriving Show
  
 instance SimpleEnum FontDraw where
         toValue FontDrawLeftToRight{} = 0
@@ -3597,7 +3639,7 @@
                                        max_char_or_byte2_QueryFontReply :: Word16,
                                        default_char_QueryFontReply :: Word16,
                                        properties_len_QueryFontReply :: Word16,
-                                       draw_direction_QueryFontReply :: Word8,
+                                       draw_direction_QueryFontReply :: FontDraw,
                                        min_byte1_QueryFontReply :: Word8,
                                        max_byte1_QueryFontReply :: Word8,
                                        all_chars_exist_QueryFontReply :: Bool,
@@ -3622,7 +3664,7 @@
                max_char_or_byte2 <- deserialize
                default_char <- deserialize
                properties_len <- deserialize
-               draw_direction <- deserialize
+               draw_direction <- liftM fromValue (deserialize :: Get Word8)
                min_byte1 <- deserialize
                max_byte1 <- deserialize
                all_chars_exist <- deserialize
@@ -3673,7 +3715,7 @@
               + sum (map size (string_QueryTextExtents x))
  
 data QueryTextExtentsReply = MkQueryTextExtentsReply{draw_direction_QueryTextExtentsReply
-                                                     :: Word8,
+                                                     :: FontDraw,
                                                      font_ascent_QueryTextExtentsReply :: Int16,
                                                      font_descent_QueryTextExtentsReply :: Int16,
                                                      overall_ascent_QueryTextExtentsReply :: Int16,
@@ -3686,7 +3728,7 @@
 instance Deserialize QueryTextExtentsReply where
         deserialize
           = do skip 1
-               draw_direction <- deserialize
+               draw_direction <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                font_ascent <- deserialize
@@ -3790,7 +3832,7 @@
                                                        properties_len_ListFontsWithInfoReply ::
                                                        Word16,
                                                        draw_direction_ListFontsWithInfoReply ::
-                                                       Word8,
+                                                       FontDraw,
                                                        min_byte1_ListFontsWithInfoReply :: Word8,
                                                        max_byte1_ListFontsWithInfoReply :: Word8,
                                                        all_chars_exist_ListFontsWithInfoReply ::
@@ -3818,7 +3860,7 @@
                max_char_or_byte2 <- deserialize
                default_char <- deserialize
                properties_len <- deserialize
-               draw_direction <- deserialize
+               draw_direction <- liftM fromValue (deserialize :: Get Word8)
                min_byte1 <- deserialize
                max_byte1 <- deserialize
                all_chars_exist <- deserialize
@@ -3944,6 +3986,7 @@
         | GCDashOffset
         | GCDashList
         | GCArcMode
+        deriving Show
  
 instance BitEnum GC where
         toBit GCFunction{} = 0
@@ -4009,6 +4052,7 @@
         | GXorInverted
         | GXnand
         | GXset
+        deriving Show
  
 instance SimpleEnum GX where
         toValue GXclear{} = 0
@@ -4047,6 +4091,7 @@
 data LineStyle = LineStyleSolid
                | LineStyleOnOffDash
                | LineStyleDoubleDash
+               deriving Show
  
 instance SimpleEnum LineStyle where
         toValue LineStyleSolid{} = 0
@@ -4060,6 +4105,7 @@
               | CapStyleButt
               | CapStyleRound
               | CapStyleProjecting
+              deriving Show
  
 instance SimpleEnum CapStyle where
         toValue CapStyleNotLast{} = 0
@@ -4074,6 +4120,7 @@
 data JoinStyle = JoinStyleMitre
                | JoinStyleRound
                | JoinStyleBevel
+               deriving Show
  
 instance SimpleEnum JoinStyle where
         toValue JoinStyleMitre{} = 0
@@ -4087,6 +4134,7 @@
                | FillStyleTiled
                | FillStyleStippled
                | FillStyleOpaqueStippled
+               deriving Show
  
 instance SimpleEnum FillStyle where
         toValue FillStyleSolid{} = 0
@@ -4100,6 +4148,7 @@
  
 data FillRule = FillRuleEvenOdd
               | FillRuleWinding
+              deriving Show
  
 instance SimpleEnum FillRule where
         toValue FillRuleEvenOdd{} = 0
@@ -4109,6 +4158,7 @@
  
 data SubwindowMode = SubwindowModeClipByChildren
                    | SubwindowModeIncludeInferiors
+                   deriving Show
  
 instance SimpleEnum SubwindowMode where
         toValue SubwindowModeClipByChildren{} = 0
@@ -4118,6 +4168,7 @@
  
 data ArcMode = ArcModeChord
              | ArcModePieSlice
+             deriving Show
  
 instance SimpleEnum ArcMode where
         toValue ArcModeChord{} = 0
@@ -4157,7 +4208,7 @@
         size x = 3 + 1 + size (gc_ChangeGC x) + size (value_ChangeGC x)
  
 data CopyGC = MkCopyGC{src_gc_CopyGC :: GCONTEXT,
-                       dst_gc_CopyGC :: GCONTEXT, value_mask_CopyGC :: Word32}
+                       dst_gc_CopyGC :: GCONTEXT, value_mask_CopyGC :: [GC]}
             deriving (Show, Typeable)
  
 instance Serialize CopyGC where
@@ -4167,11 +4218,11 @@
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (src_gc_CopyGC x)
                serialize (dst_gc_CopyGC x)
-               serialize (value_mask_CopyGC x)
+               serialize (toMask (value_mask_CopyGC x) :: Word32)
                putSkip (requiredPadding (size x))
         size x
           = 3 + 1 + size (src_gc_CopyGC x) + size (dst_gc_CopyGC x) +
-              size (value_mask_CopyGC x)
+              size (undefined :: Word32)
  
 data SetDashes = MkSetDashes{gc_SetDashes :: GCONTEXT,
                              dash_offset_SetDashes :: Word16, dashes_len_SetDashes :: Word16,
@@ -4197,6 +4248,7 @@
                   | ClipOrderingYSorted
                   | ClipOrderingYXSorted
                   | ClipOrderingYXBanded
+                  deriving Show
  
 instance SimpleEnum ClipOrdering where
         toValue ClipOrderingUnsorted{} = 0
@@ -4209,7 +4261,7 @@
         fromValue 3 = ClipOrderingYXBanded
  
 data SetClipRectangles = MkSetClipRectangles{ordering_SetClipRectangles
-                                             :: Word8,
+                                             :: ClipOrdering,
                                              gc_SetClipRectangles :: GCONTEXT,
                                              clip_x_origin_SetClipRectangles :: Int16,
                                              clip_y_origin_SetClipRectangles :: Int16,
@@ -4219,7 +4271,7 @@
 instance Serialize SetClipRectangles where
         serialize x
           = do putWord8 59
-               serialize (ordering_SetClipRectangles x)
+               serialize (toValue (ordering_SetClipRectangles x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (gc_SetClipRectangles x)
                serialize (clip_x_origin_SetClipRectangles x)
@@ -4227,9 +4279,8 @@
                serializeList (rectangles_SetClipRectangles x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (ordering_SetClipRectangles x) +
-              size (gc_SetClipRectangles x)
-              + size (clip_x_origin_SetClipRectangles x)
+          = 3 + size (undefined :: Word8) + size (gc_SetClipRectangles x) +
+              size (clip_x_origin_SetClipRectangles x)
               + size (clip_y_origin_SetClipRectangles x)
               + sum (map size (rectangles_SetClipRectangles x))
  
@@ -4340,6 +4391,7 @@
  
 data CoordMode = CoordModeOrigin
                | CoordModePrevious
+               deriving Show
  
 instance SimpleEnum CoordMode where
         toValue CoordModeOrigin{} = 0
@@ -4347,7 +4399,8 @@
         fromValue 0 = CoordModeOrigin
         fromValue 1 = CoordModePrevious
  
-data PolyPoint = MkPolyPoint{coordinate_mode_PolyPoint :: Word8,
+data PolyPoint = MkPolyPoint{coordinate_mode_PolyPoint ::
+                             CoordMode,
                              drawable_PolyPoint :: DRAWABLE, gc_PolyPoint :: GCONTEXT,
                              points_PolyPoint :: [POINT]}
                deriving (Show, Typeable)
@@ -4355,19 +4408,18 @@
 instance Serialize PolyPoint where
         serialize x
           = do putWord8 64
-               serialize (coordinate_mode_PolyPoint x)
+               serialize (toValue (coordinate_mode_PolyPoint x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_PolyPoint x)
                serialize (gc_PolyPoint x)
                serializeList (points_PolyPoint x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (coordinate_mode_PolyPoint x) +
-              size (drawable_PolyPoint x)
-              + size (gc_PolyPoint x)
+          = 3 + size (undefined :: Word8) + size (drawable_PolyPoint x) +
+              size (gc_PolyPoint x)
               + sum (map size (points_PolyPoint x))
  
-data PolyLine = MkPolyLine{coordinate_mode_PolyLine :: Word8,
+data PolyLine = MkPolyLine{coordinate_mode_PolyLine :: CoordMode,
                            drawable_PolyLine :: DRAWABLE, gc_PolyLine :: GCONTEXT,
                            points_PolyLine :: [POINT]}
               deriving (Show, Typeable)
@@ -4375,16 +4427,15 @@
 instance Serialize PolyLine where
         serialize x
           = do putWord8 65
-               serialize (coordinate_mode_PolyLine x)
+               serialize (toValue (coordinate_mode_PolyLine x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_PolyLine x)
                serialize (gc_PolyLine x)
                serializeList (points_PolyLine x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (coordinate_mode_PolyLine x) +
-              size (drawable_PolyLine x)
-              + size (gc_PolyLine x)
+          = 3 + size (undefined :: Word8) + size (drawable_PolyLine x) +
+              size (gc_PolyLine x)
               + sum (map size (points_PolyLine x))
  
 data SEGMENT = MkSEGMENT{x1_SEGMENT :: Int16, y1_SEGMENT :: Int16,
@@ -4466,6 +4517,7 @@
 data PolyShape = PolyShapeComplex
                | PolyShapeNonconvex
                | PolyShapeConvex
+               deriving Show
  
 instance SimpleEnum PolyShape where
         toValue PolyShapeComplex{} = 0
@@ -4476,8 +4528,8 @@
         fromValue 2 = PolyShapeConvex
  
 data FillPoly = MkFillPoly{drawable_FillPoly :: DRAWABLE,
-                           gc_FillPoly :: GCONTEXT, shape_FillPoly :: Word8,
-                           coordinate_mode_FillPoly :: Word8, points_FillPoly :: [POINT]}
+                           gc_FillPoly :: GCONTEXT, shape_FillPoly :: PolyShape,
+                           coordinate_mode_FillPoly :: CoordMode, points_FillPoly :: [POINT]}
               deriving (Show, Typeable)
  
 instance Serialize FillPoly where
@@ -4487,15 +4539,15 @@
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_FillPoly x)
                serialize (gc_FillPoly x)
-               serialize (shape_FillPoly x)
-               serialize (coordinate_mode_FillPoly x)
+               serialize (toValue (shape_FillPoly x) :: Word8)
+               serialize (toValue (coordinate_mode_FillPoly x) :: Word8)
                putSkip 2
                serializeList (points_FillPoly x)
                putSkip (requiredPadding (size x))
         size x
           = 3 + 1 + size (drawable_FillPoly x) + size (gc_FillPoly x) +
-              size (shape_FillPoly x)
-              + size (coordinate_mode_FillPoly x)
+              size (undefined :: Word8)
+              + size (undefined :: Word8)
               + 2
               + sum (map size (points_FillPoly x))
  
@@ -4539,6 +4591,7 @@
 data ImageFormat = ImageFormatXYBitmap
                  | ImageFormatXYPixmap
                  | ImageFormatZPixmap
+                 deriving Show
  
 instance SimpleEnum ImageFormat where
         toValue ImageFormatXYBitmap{} = 0
@@ -4548,7 +4601,7 @@
         fromValue 1 = ImageFormatXYPixmap
         fromValue 2 = ImageFormatZPixmap
  
-data PutImage = MkPutImage{format_PutImage :: Word8,
+data PutImage = MkPutImage{format_PutImage :: ImageFormat,
                            drawable_PutImage :: DRAWABLE, gc_PutImage :: GCONTEXT,
                            width_PutImage :: Word16, height_PutImage :: Word16,
                            dst_x_PutImage :: Int16, dst_y_PutImage :: Int16,
@@ -4559,7 +4612,7 @@
 instance Serialize PutImage where
         serialize x
           = do putWord8 72
-               serialize (format_PutImage x)
+               serialize (toValue (format_PutImage x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_PutImage x)
                serialize (gc_PutImage x)
@@ -4573,7 +4626,7 @@
                serializeList (data_PutImage x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (format_PutImage x) + size (drawable_PutImage x) +
+          = 3 + size (undefined :: Word8) + size (drawable_PutImage x) +
               size (gc_PutImage x)
               + size (width_PutImage x)
               + size (height_PutImage x)
@@ -4584,7 +4637,7 @@
               + 2
               + sum (map size (data_PutImage x))
  
-data GetImage = MkGetImage{format_GetImage :: Word8,
+data GetImage = MkGetImage{format_GetImage :: ImageFormat,
                            drawable_GetImage :: DRAWABLE, x_GetImage :: Int16,
                            y_GetImage :: Int16, width_GetImage :: Word16,
                            height_GetImage :: Word16, plane_mask_GetImage :: Word32}
@@ -4593,7 +4646,7 @@
 instance Serialize GetImage where
         serialize x
           = do putWord8 73
-               serialize (format_GetImage x)
+               serialize (toValue (format_GetImage x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_GetImage x)
                serialize (x_GetImage x)
@@ -4603,7 +4656,7 @@
                serialize (plane_mask_GetImage x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (format_GetImage x) + size (drawable_GetImage x) +
+          = 3 + size (undefined :: Word8) + size (drawable_GetImage x) +
               size (x_GetImage x)
               + size (y_GetImage x)
               + size (width_GetImage x)
@@ -4722,6 +4775,7 @@
  
 data ColormapAlloc = ColormapAllocNone
                    | ColormapAllocAll
+                   deriving Show
  
 instance SimpleEnum ColormapAlloc where
         toValue ColormapAllocNone{} = 0
@@ -4730,7 +4784,7 @@
         fromValue 1 = ColormapAllocAll
  
 data CreateColormap = MkCreateColormap{alloc_CreateColormap ::
-                                       Word8,
+                                       ColormapAlloc,
                                        mid_CreateColormap :: COLORMAP,
                                        window_CreateColormap :: WINDOW,
                                        visual_CreateColormap :: VISUALID}
@@ -4739,14 +4793,14 @@
 instance Serialize CreateColormap where
         serialize x
           = do putWord8 78
-               serialize (alloc_CreateColormap x)
+               serialize (toValue (alloc_CreateColormap x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (mid_CreateColormap x)
                serialize (window_CreateColormap x)
                serialize (visual_CreateColormap x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (alloc_CreateColormap x) + size (mid_CreateColormap x) +
+          = 3 + size (undefined :: Word8) + size (mid_CreateColormap x) +
               size (window_CreateColormap x)
               + size (visual_CreateColormap x)
  
@@ -5048,6 +5102,7 @@
 data ColorFlag = ColorFlagRed
                | ColorFlagGreen
                | ColorFlagBlue
+               deriving Show
  
 instance BitEnum ColorFlag where
         toBit ColorFlagRed{} = 0
@@ -5059,7 +5114,7 @@
  
 data COLORITEM = MkCOLORITEM{pixel_COLORITEM :: Word32,
                              red_COLORITEM :: Word16, green_COLORITEM :: Word16,
-                             blue_COLORITEM :: Word16, flags_COLORITEM :: Word8}
+                             blue_COLORITEM :: Word16, flags_COLORITEM :: [ColorFlag]}
                deriving (Show, Typeable)
  
 instance Serialize COLORITEM where
@@ -5068,13 +5123,13 @@
                serialize (red_COLORITEM x)
                serialize (green_COLORITEM x)
                serialize (blue_COLORITEM x)
-               serialize (flags_COLORITEM x)
+               serialize (toMask (flags_COLORITEM x) :: Word8)
                putSkip 1
         size x
           = size (pixel_COLORITEM x) + size (red_COLORITEM x) +
               size (green_COLORITEM x)
               + size (blue_COLORITEM x)
-              + size (flags_COLORITEM x)
+              + size (undefined :: Word8)
               + 1
  
 instance Deserialize COLORITEM where
@@ -5083,7 +5138,7 @@
                red <- deserialize
                green <- deserialize
                blue <- deserialize
-               flags <- deserialize
+               flags <- liftM fromMask (deserialize :: Get Word8)
                skip 1
                return (MkCOLORITEM pixel red green blue flags)
  
@@ -5104,7 +5159,7 @@
               sum (map size (items_StoreColors x))
  
 data StoreNamedColor = MkStoreNamedColor{flags_StoreNamedColor ::
-                                         Word8,
+                                         [ColorFlag],
                                          cmap_StoreNamedColor :: COLORMAP,
                                          pixel_StoreNamedColor :: Word32,
                                          name_len_StoreNamedColor :: Word16,
@@ -5114,7 +5169,7 @@
 instance Serialize StoreNamedColor where
         serialize x
           = do putWord8 90
-               serialize (flags_StoreNamedColor x)
+               serialize (toMask (flags_StoreNamedColor x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (cmap_StoreNamedColor x)
                serialize (pixel_StoreNamedColor x)
@@ -5123,9 +5178,8 @@
                serializeList (name_StoreNamedColor x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (flags_StoreNamedColor x) +
-              size (cmap_StoreNamedColor x)
-              + size (pixel_StoreNamedColor x)
+          = 3 + size (undefined :: Word8) + size (cmap_StoreNamedColor x) +
+              size (pixel_StoreNamedColor x)
               + size (name_len_StoreNamedColor x)
               + 2
               + sum (map size (name_StoreNamedColor x))
@@ -5361,6 +5415,7 @@
 data QueryShapeOf = QueryShapeOfLargestCursor
                   | QueryShapeOfFastestTile
                   | QueryShapeOfFastestStipple
+                  deriving Show
  
 instance SimpleEnum QueryShapeOf where
         toValue QueryShapeOfLargestCursor{} = 0
@@ -5370,7 +5425,8 @@
         fromValue 1 = QueryShapeOfFastestTile
         fromValue 2 = QueryShapeOfFastestStipple
  
-data QueryBestSize = MkQueryBestSize{class_QueryBestSize :: Word8,
+data QueryBestSize = MkQueryBestSize{class_QueryBestSize ::
+                                     QueryShapeOf,
                                      drawable_QueryBestSize :: DRAWABLE,
                                      width_QueryBestSize :: Word16, height_QueryBestSize :: Word16}
                    deriving (Show, Typeable)
@@ -5378,16 +5434,15 @@
 instance Serialize QueryBestSize where
         serialize x
           = do putWord8 97
-               serialize (class_QueryBestSize x)
+               serialize (toValue (class_QueryBestSize x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (drawable_QueryBestSize x)
                serialize (width_QueryBestSize x)
                serialize (height_QueryBestSize x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (class_QueryBestSize x) +
-              size (drawable_QueryBestSize x)
-              + size (width_QueryBestSize x)
+          = 3 + size (undefined :: Word8) + size (drawable_QueryBestSize x) +
+              size (width_QueryBestSize x)
               + size (height_QueryBestSize x)
  
 data QueryBestSizeReply = MkQueryBestSizeReply{width_QueryBestSizeReply
@@ -5538,6 +5593,7 @@
         | KBLedMode
         | KBKey
         | KBAutoRepeatMode
+        deriving Show
  
 instance BitEnum KB where
         toBit KBKeyClickPercent{} = 0
@@ -5559,6 +5615,7 @@
  
 data LedMode = LedModeOff
              | LedModeOn
+             deriving Show
  
 instance SimpleEnum LedMode where
         toValue LedModeOff{} = 0
@@ -5569,6 +5626,7 @@
 data AutoRepeatMode = AutoRepeatModeOff
                     | AutoRepeatModeOn
                     | AutoRepeatModeDefault
+                    deriving Show
  
 instance SimpleEnum AutoRepeatMode where
         toValue AutoRepeatModeOff{} = 0
@@ -5603,7 +5661,7 @@
         size x = 4
  
 data GetKeyboardControlReply = MkGetKeyboardControlReply{global_auto_repeat_GetKeyboardControlReply
-                                                         :: Word8,
+                                                         :: AutoRepeatMode,
                                                          led_mask_GetKeyboardControlReply :: Word32,
                                                          key_click_percent_GetKeyboardControlReply
                                                          :: Word8,
@@ -5620,7 +5678,7 @@
 instance Deserialize GetKeyboardControlReply where
         deserialize
           = do skip 1
-               global_auto_repeat <- deserialize
+               global_auto_repeat <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                led_mask <- deserialize
@@ -5714,6 +5772,7 @@
 data Blanking = BlankingNotPreferred
               | BlankingPreferred
               | BlankingDefault
+              deriving Show
  
 instance SimpleEnum Blanking where
         toValue BlankingNotPreferred{} = 0
@@ -5726,6 +5785,7 @@
 data Exposures = ExposuresNotAllowed
                | ExposuresAllowed
                | ExposuresDefault
+               deriving Show
  
 instance SimpleEnum Exposures where
         toValue ExposuresNotAllowed{} = 0
@@ -5738,8 +5798,8 @@
 data SetScreenSaver = MkSetScreenSaver{timeout_SetScreenSaver ::
                                        Int16,
                                        interval_SetScreenSaver :: Int16,
-                                       prefer_blanking_SetScreenSaver :: Word8,
-                                       allow_exposures_SetScreenSaver :: Word8}
+                                       prefer_blanking_SetScreenSaver :: Blanking,
+                                       allow_exposures_SetScreenSaver :: Exposures}
                     deriving (Show, Typeable)
  
 instance Serialize SetScreenSaver where
@@ -5749,14 +5809,14 @@
                serialize (convertBytesToRequestSize (size x) :: Int16)
                serialize (timeout_SetScreenSaver x)
                serialize (interval_SetScreenSaver x)
-               serialize (prefer_blanking_SetScreenSaver x)
-               serialize (allow_exposures_SetScreenSaver x)
+               serialize (toValue (prefer_blanking_SetScreenSaver x) :: Word8)
+               serialize (toValue (allow_exposures_SetScreenSaver x) :: Word8)
                putSkip (requiredPadding (size x))
         size x
           = 3 + 1 + size (timeout_SetScreenSaver x) +
               size (interval_SetScreenSaver x)
-              + size (prefer_blanking_SetScreenSaver x)
-              + size (allow_exposures_SetScreenSaver x)
+              + size (undefined :: Word8)
+              + size (undefined :: Word8)
  
 data GetScreenSaver = MkGetScreenSaver{}
                     deriving (Show, Typeable)
@@ -5772,8 +5832,8 @@
 data GetScreenSaverReply = MkGetScreenSaverReply{timeout_GetScreenSaverReply
                                                  :: Word16,
                                                  interval_GetScreenSaverReply :: Word16,
-                                                 prefer_blanking_GetScreenSaverReply :: Word8,
-                                                 allow_exposures_GetScreenSaverReply :: Word8}
+                                                 prefer_blanking_GetScreenSaverReply :: Blanking,
+                                                 allow_exposures_GetScreenSaverReply :: Exposures}
                          deriving (Show, Typeable)
  
 instance Deserialize GetScreenSaverReply where
@@ -5784,8 +5844,8 @@
                length <- deserialize
                timeout <- deserialize
                interval <- deserialize
-               prefer_blanking <- deserialize
-               allow_exposures <- deserialize
+               prefer_blanking <- liftM fromValue (deserialize :: Get Word8)
+               allow_exposures <- liftM fromValue (deserialize :: Get Word8)
                skip 18
                let _ = isCard32 length
                return
@@ -5794,6 +5854,7 @@
  
 data HostMode = HostModeInsert
               | HostModeDelete
+              deriving Show
  
 instance SimpleEnum HostMode where
         toValue HostModeInsert{} = 0
@@ -5806,6 +5867,7 @@
             | FamilyChaos
             | FamilyServerInterpreted
             | FamilyInternet6
+            deriving Show
  
 instance SimpleEnum Family where
         toValue FamilyInternet{} = 0
@@ -5819,43 +5881,43 @@
         fromValue 5 = FamilyServerInterpreted
         fromValue 6 = FamilyInternet6
  
-data ChangeHosts = MkChangeHosts{mode_ChangeHosts :: Word8,
-                                 family_ChangeHosts :: Word8, address_len_ChangeHosts :: Word16,
+data ChangeHosts = MkChangeHosts{mode_ChangeHosts :: HostMode,
+                                 family_ChangeHosts :: Family, address_len_ChangeHosts :: Word16,
                                  address_ChangeHosts :: [CChar]}
                  deriving (Show, Typeable)
  
 instance Serialize ChangeHosts where
         serialize x
           = do putWord8 109
-               serialize (mode_ChangeHosts x)
+               serialize (toValue (mode_ChangeHosts x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
-               serialize (family_ChangeHosts x)
+               serialize (toValue (family_ChangeHosts x) :: Word8)
                putSkip 1
                serialize (address_len_ChangeHosts x)
                serializeList (address_ChangeHosts x)
                putSkip (requiredPadding (size x))
         size x
-          = 3 + size (mode_ChangeHosts x) + size (family_ChangeHosts x) + 1 +
+          = 3 + size (undefined :: Word8) + size (undefined :: Word8) + 1 +
               size (address_len_ChangeHosts x)
               + sum (map size (address_ChangeHosts x))
  
-data HOST = MkHOST{family_HOST :: Word8,
+data HOST = MkHOST{family_HOST :: Family,
                    address_len_HOST :: Word16, address_HOST :: [Word8]}
           deriving (Show, Typeable)
  
 instance Serialize HOST where
         serialize x
-          = do serialize (family_HOST x)
+          = do serialize (toValue (family_HOST x) :: Word8)
                putSkip 1
                serialize (address_len_HOST x)
                serializeList (address_HOST x)
         size x
-          = size (family_HOST x) + 1 + size (address_len_HOST x) +
+          = size (undefined :: Word8) + 1 + size (address_len_HOST x) +
               sum (map size (address_HOST x))
  
 instance Deserialize HOST where
         deserialize
-          = do family <- deserialize
+          = do family <- liftM fromValue (deserialize :: Get Word8)
                skip 1
                address_len <- deserialize
                address <- deserializeList (fromIntegral address_len)
@@ -5873,7 +5935,7 @@
         size x = 4
  
 data ListHostsReply = MkListHostsReply{mode_ListHostsReply ::
-                                       Word8,
+                                       AccessControl,
                                        hosts_len_ListHostsReply :: Word16,
                                        hosts_ListHostsReply :: [HOST]}
                     deriving (Show, Typeable)
@@ -5881,7 +5943,7 @@
 instance Deserialize ListHostsReply where
         deserialize
           = do skip 1
-               mode <- deserialize
+               mode <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                hosts_len <- deserialize
@@ -5892,6 +5954,7 @@
  
 data AccessControl = AccessControlDisable
                    | AccessControlEnable
+                   deriving Show
  
 instance SimpleEnum AccessControl where
         toValue AccessControlDisable{} = 0
@@ -5900,20 +5963,21 @@
         fromValue 1 = AccessControlEnable
  
 data SetAccessControl = MkSetAccessControl{mode_SetAccessControl ::
-                                           Word8}
+                                           AccessControl}
                       deriving (Show, Typeable)
  
 instance Serialize SetAccessControl where
         serialize x
           = do putWord8 111
-               serialize (mode_SetAccessControl x)
+               serialize (toValue (mode_SetAccessControl x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                putSkip (requiredPadding (size x))
-        size x = 3 + size (mode_SetAccessControl x)
+        size x = 3 + size (undefined :: Word8)
  
 data CloseDown = CloseDownDestroyAll
                | CloseDownRetainPermanent
                | CloseDownRetainTemporary
+               deriving Show
  
 instance SimpleEnum CloseDown where
         toValue CloseDownDestroyAll{} = 0
@@ -5924,24 +5988,25 @@
         fromValue 2 = CloseDownRetainTemporary
  
 data SetCloseDownMode = MkSetCloseDownMode{mode_SetCloseDownMode ::
-                                           Word8}
+                                           CloseDown}
                       deriving (Show, Typeable)
  
 instance Serialize SetCloseDownMode where
         serialize x
           = do putWord8 112
-               serialize (mode_SetCloseDownMode x)
+               serialize (toValue (mode_SetCloseDownMode x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                putSkip (requiredPadding (size x))
-        size x = 3 + size (mode_SetCloseDownMode x)
+        size x = 3 + size (undefined :: Word8)
  
 data Kill = KillAllTemporary
+          deriving Show
  
 instance SimpleEnum Kill where
         toValue KillAllTemporary{} = 0
         fromValue 0 = KillAllTemporary
  
-data KillClient = MkKillClient{resource_KillClient :: Word32}
+data KillClient = MkKillClient{resource_KillClient :: Kill}
                 deriving (Show, Typeable)
  
 instance Serialize KillClient where
@@ -5949,9 +6014,9 @@
           = do putWord8 113
                putSkip 1
                serialize (convertBytesToRequestSize (size x) :: Int16)
-               serialize (resource_KillClient x)
+               serialize (toValue (resource_KillClient x) :: Word32)
                putSkip (requiredPadding (size x))
-        size x = 3 + 1 + size (resource_KillClient x)
+        size x = 3 + 1 + size (undefined :: Word32)
  
 data RotateProperties = MkRotateProperties{window_RotateProperties
                                            :: WINDOW,
@@ -5978,6 +6043,7 @@
  
 data ScreenSaver = ScreenSaverReset
                  | ScreenSaverActive
+                 deriving Show
  
 instance SimpleEnum ScreenSaver where
         toValue ScreenSaverReset{} = 0
@@ -5986,20 +6052,21 @@
         fromValue 1 = ScreenSaverActive
  
 data ForceScreenSaver = MkForceScreenSaver{mode_ForceScreenSaver ::
-                                           Word8}
+                                           ScreenSaver}
                       deriving (Show, Typeable)
  
 instance Serialize ForceScreenSaver where
         serialize x
           = do putWord8 115
-               serialize (mode_ForceScreenSaver x)
+               serialize (toValue (mode_ForceScreenSaver x) :: Word8)
                serialize (convertBytesToRequestSize (size x) :: Int16)
                putSkip (requiredPadding (size x))
-        size x = 3 + size (mode_ForceScreenSaver x)
+        size x = 3 + size (undefined :: Word8)
  
 data MappingStatus = MappingStatusSuccess
                    | MappingStatusBusy
                    | MappingStatusFailure
+                   deriving Show
  
 instance SimpleEnum MappingStatus where
         toValue MappingStatusSuccess{} = 0
@@ -6026,13 +6093,13 @@
               sum (map size (map_SetPointerMapping x))
  
 data SetPointerMappingReply = MkSetPointerMappingReply{status_SetPointerMappingReply
-                                                       :: Word8}
+                                                       :: MappingStatus}
                             deriving (Show, Typeable)
  
 instance Deserialize SetPointerMappingReply where
         deserialize
           = do skip 1
-               status <- deserialize
+               status <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                let _ = isCard32 length
@@ -6073,6 +6140,7 @@
               | MapIndex3
               | MapIndex4
               | MapIndex5
+              deriving Show
  
 instance SimpleEnum MapIndex where
         toValue MapIndexShift{} = 0
@@ -6109,13 +6177,13 @@
               sum (map size (keycodes_SetModifierMapping x))
  
 data SetModifierMappingReply = MkSetModifierMappingReply{status_SetModifierMappingReply
-                                                         :: Word8}
+                                                         :: MappingStatus}
                              deriving (Show, Typeable)
  
 instance Deserialize SetModifierMappingReply where
         deserialize
           = do skip 1
-               status <- deserialize
+               status <- liftM fromValue (deserialize :: Get Word8)
                skip 2
                length <- deserialize
                let _ = isCard32 length
diff --git a/patched/Graphics/XHB/Gen/Xv/Types.hs b/patched/Graphics/XHB/Gen/Xv/Types.hs
--- a/patched/Graphics/XHB/Gen/Xv/Types.hs
+++ b/patched/Graphics/XHB/Gen/Xv/Types.hs
@@ -59,6 +59,7 @@
           | TypeVideoMask
           | TypeStillMask
           | TypeImageMask
+          deriving Show
  
 instance BitEnum Type where
         toBit TypeInputMask{} = 0
@@ -74,6 +75,7 @@
  
 data ImageFormatInfoType = ImageFormatInfoTypeRGB
                          | ImageFormatInfoTypeYUV
+                         deriving Show
  
 instance SimpleEnum ImageFormatInfoType where
         toValue ImageFormatInfoTypeRGB{} = 0
@@ -83,6 +85,7 @@
  
 data ImageFormatInfoFormat = ImageFormatInfoFormatPacked
                            | ImageFormatInfoFormatPlanar
+                           deriving Show
  
 instance SimpleEnum ImageFormatInfoFormat where
         toValue ImageFormatInfoFormatPacked{} = 0
@@ -92,6 +95,7 @@
  
 data AttributeFlag = AttributeFlagGettable
                    | AttributeFlagSettable
+                   deriving Show
  
 instance BitEnum AttributeFlag where
         toBit AttributeFlagGettable{} = 0
diff --git a/xhb.cabal b/xhb.cabal
--- a/xhb.cabal
+++ b/xhb.cabal
@@ -1,5 +1,5 @@
 Name:         xhb
-Version:      0.1.2009.2.8
+Version:      0.2.2009.2.21
 Cabal-Version:  >= 1.2.3
 Synopsis:     X Haskell Bindings
 Description:
@@ -7,7 +7,7 @@
   .
   Similar to XCB - the X C Bindings.
   .
-  This library is based on version 1.3 of the xcb-proto
+  This library is based on version 1.4 of the xcb-proto
   package.  See http:\/\/xcb.freedesktop.org\/XmlXcb\/ and
   http:\/\/xcb.freedesktop.org\/dist\/ .
 
