 
   alignment _ = alignment (undefined :: Word32)
 
-  peek ptr = agg `fmap` peekBE (castPtr ptr :: Ptr Word32)
+  peek ptr = agg <$> peekBE (castPtr ptr :: Ptr Word32)
     where
     agg 1 = Average
     agg 2 = Sum


  alignment _ = alignment (undefined :: Word32)

  peek ptr = do
    a <- peek (castPtr ptr)
    b <- fromIntegral `fmap` peekBE (castPtr ptr `plusPtr` 4 :: Ptr Word32)
    c <- coerce `fmap` peekBE (castPtr ptr `plusPtr` 8)
    d <- fromIntegral `fmap` peekBE (castPtr ptr `plusPtr` 12 :: Ptr Word32)
    return $ MetaData a b c d
    where
    coerce :: Word32 -> Float
    coerce x = unsafePerformIO $ with x $ \p ->
      peek (castPtr p) :: IO Float

  poke ptr MetaData{..} = do
    poke (castPtr ptr) mdAggregationType


  alignment _ = alignment (undefined :: Word32)

  peek ptr = ArchiveInfo
    <$> peekWord32beAsNum (castPtr ptr)
    <*> peekWord32beAsNum (castPtr ptr `plusPtr` 4)
    <*> peekWord32beAsNum (castPtr ptr `plusPtr` 8)

  poke ptr ArchiveInfo{..} = do
    pokeBE (castPtr ptr) (fromIntegral aiOffset :: Word32)
