packages feed

byteorder 1.0.0 → 1.0.1

raw patch · 2 files changed

+16/−16 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

System/ByteOrder.hs view
@@ -9,14 +9,12 @@ Portability: requires FFI  -}++{-# OPTIONS_GHC -fno-cse #-}+ module System.ByteOrder(byteOrder, ByteOrder(..)) where -import Foreign.Marshal.Array-import Foreign.Marshal.Alloc-import Foreign.Storable-import Foreign.Ptr import Foreign- import Data.Word  -- |Indicates the byte-ordering for a 4-byte value, where '1'@@ -39,18 +37,20 @@  -- |Returns the native byte ordering of the system. byteOrder :: ByteOrder-byteOrder = unsafePerformIO $ byteOrderIO+byteOrder = unsafePerformIO byteOrderIO+{-# NOINLINE byteOrder #-}  byteOrderIO :: IO ByteOrder-byteOrderIO = byteListToByteOrder `fmap` wordToByteList input+byteOrderIO = bytesToByteOrder `fmap` wordToBytes input -wordToByteList :: Word32 -> IO [Word8]-wordToByteList word = alloca $ \wordPtr -> do-         poke wordPtr input-         peekArray 4 (castPtr wordPtr)+wordToBytes :: Word32 -> IO (Word8,Word8,Word8,Word8)+wordToBytes word = alloca $ \wordPtr -> do+         poke wordPtr word+         [x1,x2,x3,x4] <- peekArray 4 (castPtr wordPtr)+         return (x1,x2,x3,x4) -byteListToByteOrder :: [Word8] -> ByteOrder-byteListToByteOrder [1, 2, 3, 4] = BigEndian-byteListToByteOrder [4, 3, 2, 1] = LittleEndian-byteListToByteOrder xs@[x1, x2, x3, x4] = Mixed (x1,x2,x3,x4)+bytesToByteOrder :: (Word8,Word8,Word8,Word8) -> ByteOrder+bytesToByteOrder (1, 2, 3, 4)     = BigEndian+bytesToByteOrder (4, 3, 2, 1)     = LittleEndian+bytesToByteOrder (x1, x2, x3, x4) = Mixed (x1,x2,x3,x4) 
byteorder.cabal view
@@ -1,5 +1,5 @@ Name:         byteorder-Version:      1.0.0+Version:      1.0.1 Cabal-Version:  >= 1.2 Synopsis:      native byte-ordering of the system Description:   This package is for working with the native byte-ordering of