 
   alignment _ = alignment (undefined :: Word32)
 
-  peek ptr = do
-    a <- fromIntegral `fmap` peekBE (castPtr ptr :: Ptr Word32)
-    b <- coerce `fmap` peekBE (castPtr ptr `plusPtr` 4)
-    return $ Point a b
-    where
-    coerce :: Word64 -> Double
-    coerce x = unsafePerformIO $ with x $ \p ->
-      peek (castPtr p) :: IO Double
+  peek ptr = Point
+    <$> peekWord32beAsNum (castPtr ptr)
+    <*> peekWord64beAsDouble (castPtr ptr `plusPtr` 4)
 
   poke ptr (Point a b) = do
     pokeBE (castPtr ptr) (fromIntegral a :: Word32)

    coerce :: Double -> Word64
    coerce x = unsafePerformIO $ with x $ \p ->
      peek (castPtr p) :: IO Word64


import Prelude hiding (Enum, fromEnum)

import Control.Applicative ((<$>), (<*>))
import Control.Exception (finally)
import Data.Bits ((.|.))
import Data.Function (on)
