network-byte-order-0.1.7: Network byte order utilities

Safe Haskell | None
Language | Haskell2010

Network.ByteOrder

Contents

- Types
- Poking
- Peeking
- From Word to ByteString
- From ByteString to Word
- Utilities
- Class to read a buffer
- Reading from buffer
- Writing to buffer
- Re-exporting

Description

Peek and poke functions for network byte order.

Synopsis

- type Buffer = Ptr Word8
- type Offset = Int
- type BufferSize = Int
- data BufferOverrun = BufferOverrun
- poke8 :: Word8 -> Buffer -> Offset -> IO ()
- poke16 :: Word16 -> Buffer -> Offset -> IO ()
- poke24 :: Word32 -> Buffer -> Offset -> IO ()
- poke32 :: Word32 -> Buffer -> Offset -> IO ()
- poke64 :: Word64 -> Buffer -> Offset -> IO ()
- peek8 :: Buffer -> Offset -> IO Word8
- peek16 :: Buffer -> Offset -> IO Word16
- peek24 :: Buffer -> Offset -> IO Word32
- peek32 :: Buffer -> Offset -> IO Word32
- peek64 :: Buffer -> Offset -> IO Word64
- peekByteString :: Buffer -> Int -> IO ByteString
- bytestring8 :: Word8 -> ByteString
- bytestring16 :: Word16 -> ByteString
- bytestring32 :: Word32 -> ByteString
- bytestring64 :: Word64 -> ByteString
- word8 :: ByteString -> Word8
- word16 :: ByteString -> Word16
- word32 :: ByteString -> Word32
- word64 :: ByteString -> Word64
- unsafeWithByteString :: ByteString -> (Buffer -> Offset -> IO a) -> IO a
- copy :: Buffer -> ByteString -> IO Buffer
- bufferIO :: Buffer -> Int -> (ByteString -> IO a) -> IO a
- class Readable a where
  - read8 :: a -> IO Word8
  - readInt8 :: a -> IO Int
  - ff :: a -> Offset -> IO ()
  - remainingSize :: a -> IO Int
  - position :: a -> IO Int
  - withCurrentOffSet :: a -> (Buffer -> IO b) -> IO b
  - save :: a -> IO ()
  - savingSize :: a -> IO Int
  - goBack :: a -> IO ()
- data ReadBuffer
- newReadBuffer :: Buffer -> BufferSize -> IO ReadBuffer
- withReadBuffer :: ByteString -> (ReadBuffer -> IO a) -> IO a
- read16 :: Readable a => a -> IO Word16
- read24 :: Readable a => a -> IO Word32
- read32 :: Readable a => a -> IO Word32
- read64 :: Readable a => a -> IO Word64
- extractByteString :: Readable a => a -> Int -> IO ByteString
- extractShortByteString :: Readable a => a -> Int -> IO ShortByteString
- data WriteBuffer = WriteBuffer {
  - start :: Buffer
  - limit :: Buffer
  - offset :: IORef Buffer
  - oldoffset :: IORef Buffer
  }
- newWriteBuffer :: Buffer -> BufferSize -> IO WriteBuffer
- clearWriteBuffer :: WriteBuffer -> IO ()
- withWriteBuffer :: BufferSize -> (WriteBuffer -> IO ()) -> IO ByteString
- withWriteBuffer' :: BufferSize -> (WriteBuffer -> IO a) -> IO (ByteString, a)
- write8 :: WriteBuffer -> Word8 -> IO ()
- write16 :: WriteBuffer -> Word16 -> IO ()
- write24 :: WriteBuffer -> Word32 -> IO ()
- write32 :: WriteBuffer -> Word32 -> IO ()
- write64 :: WriteBuffer -> Word64 -> IO ()
- copyByteString :: WriteBuffer -> ByteString -> IO ()
- copyShortByteString :: WriteBuffer -> ShortByteString -> IO ()
- shiftLastN :: WriteBuffer -> Int -> Int -> IO ()
- toByteString :: WriteBuffer -> IO ByteString
- toShortByteString :: WriteBuffer -> IO ShortByteString
- currentOffset :: WriteBuffer -> IO Buffer
- data Word8
- data Word16
- data Word32
- data Word64
- data ByteString

# Types

type Buffer = Ptr Word8 Source #

A pointer to `Word8`.

type Offset = Int Source #

Offset from the current pointer.

type BufferSize = Int Source #

Size of a buffer.

data BufferOverrun Source #

Buffer overrun exception.

Constructors

BufferOverrun | The buffer size is not enough

#### Instances

Instances details

Exception BufferOverrun Source # |
Instance details Defined in Network.ByteOrder Methods toException :: BufferOverrun -> SomeException Source # fromException :: SomeException -> Maybe BufferOverrun Source # displayException :: BufferOverrun -> String Source # backtraceDesired :: BufferOverrun -> Bool Source #
Show BufferOverrun Source # |
Instance details Defined in Network.ByteOrder Methods showsPrec :: Int -> BufferOverrun -> ShowS Source # show :: BufferOverrun -> String Source # showList :: [BufferOverrun] -> ShowS Source #
Eq BufferOverrun Source # |
Instance details Defined in Network.ByteOrder Methods (==) :: BufferOverrun -> BufferOverrun -> Bool Source # (/=) :: BufferOverrun -> BufferOverrun -> Bool Source #

# Poking

poke8 :: Word8 -> Buffer -> Offset -> IO () Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf (poke8 0)
    >>> unpack buf
    [0,2,3,4]

poke16 :: Word16 -> Buffer -> Offset -> IO () Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf (poke16 (7*256 + 8))
    >>> unpack buf
    [7,8,3,4]

poke24 :: Word32 -> Buffer -> Offset -> IO () Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf (poke24 (6*65536 + 7*256 + 8))
    >>> unpack buf
    [6,7,8,4]

poke32 :: Word32 -> Buffer -> Offset -> IO () Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf (poke32 (6*65536 + 7*256 + 8))
    >>> unpack buf
    [0,6,7,8]

poke64 :: Word64 -> Buffer -> Offset -> IO () Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> unsafeWithByteString buf (poke64 (6*65536 + 7*256 + 8))
    >>> unpack buf
    [0,0,0,0,0,6,7,8]

# Peeking

peek8 :: Buffer -> Offset -> IO Word8 Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf peek8
    1

peek16 :: Buffer -> Offset -> IO Word16 Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf peek16
    258

peek24 :: Buffer -> Offset -> IO Word32 Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf peek24
    66051

peek32 :: Buffer -> Offset -> IO Word32 Source #

    >>> let buf = pack [1,2,3,4]
    >>> unsafeWithByteString buf peek32
    16909060

peek64 :: Buffer -> Offset -> IO Word64 Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> unsafeWithByteString buf peek64
    72623859790382856

peekByteString :: Buffer -> Int -> IO ByteString Source #

# From Word to ByteString

bytestring8 :: Word8 -> ByteString Source #

    >>> let w = 5 :: Word8
    >>> unpack $ bytestring8 w
    [5]

bytestring16 :: Word16 -> ByteString Source #

    >>> let w = foldl' (\x y -> x * 256 + y) 0 [5,6] :: Word16
    >>> unpack $ bytestring16 w
    [5,6]

bytestring32 :: Word32 -> ByteString Source #

    >>> let w = foldl' (\x y -> x * 256 + y) 0 [5,6,7,8] :: Word32
    >>> unpack $ bytestring32 w
    [5,6,7,8]

bytestring64 :: Word64 -> ByteString Source #

    >>> let w = foldl' (\x y -> x * 256 + y) 0 [1,2,3,4,5,6,7,8] :: Word64
    >>> unpack $ bytestring64 w
    [1,2,3,4,5,6,7,8]

# From ByteString to Word

word8 :: ByteString -> Word8 Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> word8 buf
    1

word16 :: ByteString -> Word16 Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> word16 buf
    258

word32 :: ByteString -> Word32 Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> word32 buf
    16909060

word64 :: ByteString -> Word64 Source #

    >>> let buf = pack [1,2,3,4,5,6,7,8]
    >>> word64 buf
    72623859790382856

# Utilities

unsafeWithByteString :: ByteString -> (Buffer -> Offset -> IO a) -> IO a Source #

Using `ByteString` as `Buffer` and call the `IO` action of the second argument by passing the start point and the offset of the `ByteString`. Note that if a `ByteString` is created newly, its offset is 0.

copy :: Buffer -> ByteString -> IO Buffer Source #

Copying the bytestring to the buffer. This function returns the point where the next copy should start.

    >>> let buf = "abc" :: ByteString
    >>> unsafeWithByteString buf $ \ptr _ -> Network.ByteOrder.copy ptr "ABC" >> return buf
    "ABC"

bufferIO :: Buffer -> Int -> (ByteString -> IO a) -> IO a Source #

Converting the part of buffer to `ByteString` and executing the action with it.

    >>> let buf = "abcdef" :: ByteString
    >>> unsafeWithByteString buf $ \ptr _-> bufferIO ptr 2 return
    "ab"

# Class to read a buffer

class Readable a where Source #

Methods

read8 :: a -> IO Word8 Source #

Reading one byte as `Word8` and ff one byte.

readInt8 :: a -> IO Int Source #

Reading one byte as `Int` and ff one byte. If buffer overrun occurs, -1 is returned.

ff :: a -> Offset -> IO () Source #

Fast forward the offset pointer. The boundary is not checked.

remainingSize :: a -> IO Int Source #

Returning the length of the remaining

position :: a -> IO Int Source #

Executing an action on the current offset pointer.

withCurrentOffSet :: a -> (Buffer -> IO b) -> IO b Source #

save :: a -> IO () Source #

Memorizing the current offset pointer.

savingSize :: a -> IO Int Source #

Getting how many bytes from the saved offset pinter.

goBack :: a -> IO () Source #

Moving the offset point to the saved point.

#### Instances

Instances details

Readable ReadBuffer Source # |

Instance details

Defined in Network.ByteOrder

Methods

read8 :: ReadBuffer -> IO Word8 Source #

readInt8 :: ReadBuffer -> IO Int Source #

ff :: ReadBuffer -> Offset -> IO () Source #

remainingSize :: ReadBuffer -> IO Int Source #

position :: ReadBuffer -> IO Int Source #

withCurrentOffSet :: ReadBuffer -> (Buffer -> IO b) -> IO b Source #

save :: ReadBuffer -> IO () Source #

savingSize :: ReadBuffer -> IO Int Source #

goBack :: ReadBuffer -> IO () Source #

Readable WriteBuffer Source # |

Instance details

Defined in Network.ByteOrder

Methods

read8 :: WriteBuffer -> IO Word8 Source #

readInt8 :: WriteBuffer -> IO Int Source #

ff :: WriteBuffer -> Offset -> IO () Source #

remainingSize :: WriteBuffer -> IO Int Source #

position :: WriteBuffer -> IO Int Source #

withCurrentOffSet :: WriteBuffer -> (Buffer -> IO b) -> IO b Source #

save :: WriteBuffer -> IO () Source #

savingSize :: WriteBuffer -> IO Int Source #

goBack :: WriteBuffer -> IO () Source #

# Reading from buffer

data ReadBuffer Source #

Read only buffer. To ensure that the internal is not modified, this is an abstract data type.

#### Instances

Instances details

Readable ReadBuffer Source # |

Instance details

Defined in Network.ByteOrder

Methods

read8 :: ReadBuffer -> IO Word8 Source #

readInt8 :: ReadBuffer -> IO Int Source #

ff :: ReadBuffer -> Offset -> IO () Source #

remainingSize :: ReadBuffer -> IO Int Source #

position :: ReadBuffer -> IO Int Source #

withCurrentOffSet :: ReadBuffer -> (Buffer -> IO b) -> IO b Source #

save :: ReadBuffer -> IO () Source #

savingSize :: ReadBuffer -> IO Int Source #

goBack :: ReadBuffer -> IO () Source #

newReadBuffer :: Buffer -> BufferSize -> IO ReadBuffer Source #

Creating a read buffer with the given buffer.

withReadBuffer :: ByteString -> (ReadBuffer -> IO a) -> IO a Source #

Converting `ByteString` to `ReadBuffer` and run the action with it.

read16 :: Readable a => a -> IO Word16 Source #

Reading two bytes as `Word16` and ff two bytes.

    >>> withReadBuffer "\x0\x1\x2\x3" $ read16
    1

read24 :: Readable a => a -> IO Word32 Source #

Reading three bytes as `Word32` and ff three bytes.

    >>> withReadBuffer "\x0\x1\x2\x3" $ read24
    258

read32 :: Readable a => a -> IO Word32 Source #

Reading four bytes as `Word32` and ff four bytes.

    >>> withReadBuffer "\x0\x1\x2\x3" $ read32
    66051

read64 :: Readable a => a -> IO Word64 Source #

Reading four bytes as `Word64` and ff four bytes.

extractByteString :: Readable a => a -> Int -> IO ByteString Source #

Extracting `ByteString` from the current offset. The contents is copied, not shared. Its length is specified by the 2nd argument. If the length is positive, the area after the current pointer is extracted and FF the length finally. If the length is negative, the area before the current pointer is extracted and does not FF.

    >>> withReadBuffer "abcdefg" $ \rbuf -> ff rbuf 1 >> extractByteString rbuf 2
    "bc"

extractShortByteString :: Readable a => a -> Int -> IO ShortByteString Source #

Extracting `ShortByteString` from the current offset. The contents is copied, not shared. Its length is specified by the 2nd argument. If the length is positive, the area after the current pointer is extracted and FF the length finally. If the length is negative, the area before the current pointer is extracted and does not FF.

    >>> withReadBuffer "abcdefg" $ \rbuf -> ff rbuf 2 >> extractShortByteString rbuf 3
    "cde"

# Writing to buffer

data WriteBuffer Source #

Read and write buffer.

Constructors

WriteBuffer |

Fields

- start :: Buffer
- limit :: Buffer
- offset :: IORef Buffer
- oldoffset :: IORef Buffer

#### Instances

Instances details

Readable WriteBuffer Source # |

Instance details

Defined in Network.ByteOrder

Methods

read8 :: WriteBuffer -> IO Word8 Source #

readInt8 :: WriteBuffer -> IO Int Source #

ff :: WriteBuffer -> Offset -> IO () Source #

remainingSize :: WriteBuffer -> IO Int Source #

position :: WriteBuffer -> IO Int Source #

withCurrentOffSet :: WriteBuffer -> (Buffer -> IO b) -> IO b Source #

save :: WriteBuffer -> IO () Source #

savingSize :: WriteBuffer -> IO Int Source #

goBack :: WriteBuffer -> IO () Source #

newWriteBuffer :: Buffer -> BufferSize -> IO WriteBuffer Source #

Creating a write buffer with the given buffer.

clearWriteBuffer :: WriteBuffer -> IO () Source #

Reseting a write buffer.

withWriteBuffer :: BufferSize -> (WriteBuffer -> IO ()) -> IO ByteString Source #

Allocate a temporary buffer and copy the result to `ByteString`.

withWriteBuffer' :: BufferSize -> (WriteBuffer -> IO a) -> IO (ByteString, a) Source #

Allocate a temporary buffer and copy the result to `ByteString` with an additional value.

    >>> withWriteBuffer' 1 $ \wbuf -> write8 wbuf 65 >> return 'a'
    ("A",'a')

write8 :: WriteBuffer -> Word8 -> IO () Source #

Write one byte and ff one byte. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 1 $ \wbuf -> write8 wbuf 65
    "A"

write16 :: WriteBuffer -> Word16 -> IO () Source #

Write two bytes and ff one byte. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 2 $ \wbuf -> write16 wbuf (65 * 256 + 66)
    "AB"

write24 :: WriteBuffer -> Word32 -> IO () Source #

Write three bytes and ff one byte. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 3 $ \wbuf -> write24 wbuf (65 * 256^(2 :: Int) + 66 * 256 + 67)
    "ABC"

write32 :: WriteBuffer -> Word32 -> IO () Source #

Write four bytes and ff one byte. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 4 $ \wbuf -> write32 wbuf (65 * 256^(3 :: Int) + 66 * 256^(2 :: Int) + 67 * 256 + 68)
    "ABCD"

write64 :: WriteBuffer -> Word64 -> IO () Source #

Write four bytes and ff one byte. If buffer overrun occurs, `BufferOverrun` is thrown.

copyByteString :: WriteBuffer -> ByteString -> IO () Source #

Copy the content of `ByteString` and ff its length. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 3 $ \wbuf -> copyByteString wbuf "ABC"
    "ABC"

copyShortByteString :: WriteBuffer -> ShortByteString -> IO () Source #

Copy the content of `ShortByteString` and ff its length. If buffer overrun occurs, `BufferOverrun` is thrown.

    >>> withWriteBuffer 5 $ \wbuf -> copyShortByteString wbuf "ABCEF"
    "ABCEF"

shiftLastN :: WriteBuffer -> Int -> Int -> IO () Source #

Shifting the N-bytes area just before the current pointer (the 3rd argument). If the second argument is positive, shift it to right. If it is negative, shift it to left. `offset` moves as if it is sticky to the area.

    >>> withWriteBuffer 16 $ \wbuf -> copyByteString wbuf "ABCD" >> shiftLastN wbuf 1 3
    "ABBCD"
    >>> withWriteBuffer 16 $ \wbuf -> copyByteString wbuf "ABCD" >> shiftLastN wbuf 2 3
    "ABCBCD"
    >>> withWriteBuffer 16 $ \wbuf -> copyByteString wbuf "ABCDE" >> shiftLastN wbuf (-2) 3 >> ff wbuf 2
    "CDEDE"

toByteString :: WriteBuffer -> IO ByteString Source #

Copy the area from `start` to the current pointer to `ByteString`.

toShortByteString :: WriteBuffer -> IO ShortByteString Source #

Copy the area from `start` to the current pointer to `ShortByteString`.

currentOffset :: WriteBuffer -> IO Buffer Source #

Getting the offset pointer.

# Re-exporting

data Word8 Source #

8-bit unsigned integer type

#### Instances

Instances details

PrintfArg Word8 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word8 -> FieldFormatter Source # parseFormat :: Word8 -> ModifierParser Source #
Bits Word8 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(.&.) :: Word8 -> Word8 -> Word8 Source #

(.|.) :: Word8 -> Word8 -> Word8 Source #

xor :: Word8 -> Word8 -> Word8 Source #

complement :: Word8 -> Word8 Source #

shift :: Word8 -> Int -> Word8 Source #

rotate :: Word8 -> Int -> Word8 Source #

zeroBits :: Word8 Source #

bit :: Int -> Word8 Source #

setBit :: Word8 -> Int -> Word8 Source #

clearBit :: Word8 -> Int -> Word8 Source #

complementBit :: Word8 -> Int -> Word8 Source #

testBit :: Word8 -> Int -> Bool Source #

bitSizeMaybe :: Word8 -> Maybe Int Source #

bitSize :: Word8 -> Int Source #

isSigned :: Word8 -> Bool Source #

shiftL :: Word8 -> Int -> Word8 Source #

unsafeShiftL :: Word8 -> Int -> Word8 Source #

shiftR :: Word8 -> Int -> Word8 Source #

unsafeShiftR :: Word8 -> Int -> Word8 Source #

rotateL :: Word8 -> Int -> Word8 Source #

rotateR :: Word8 -> Int -> Word8 Source #

popCount :: Word8 -> Int Source #

FiniteBits Word8 | Since: base-4.6.0.0
Instance details Defined in GHC.Internal.Word Methods finiteBitSize :: Word8 -> Int Source # countLeadingZeros :: Word8 -> Int Source # countTrailingZeros :: Word8 -> Int Source #
Bounded Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods minBound :: Word8 Source # maxBound :: Word8 Source #
Enum Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods succ :: Word8 -> Word8 Source # pred :: Word8 -> Word8 Source # toEnum :: Int -> Word8 Source # fromEnum :: Word8 -> Int Source # enumFrom :: Word8 -> [Word8] Source # enumFromThen :: Word8 -> Word8 -> [Word8] Source # enumFromTo :: Word8 -> Word8 -> [Word8] Source # enumFromThenTo :: Word8 -> Word8 -> Word8 -> [Word8] Source #
Storable Word8 | Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Word8 -> Int Source #

alignment :: Word8 -> Int Source #

peekElemOff :: Ptr Word8 -> Int -> IO Word8 Source #

pokeElemOff :: Ptr Word8 -> Int -> Word8 -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Word8 Source #

pokeByteOff :: Ptr b -> Int -> Word8 -> IO () Source #

peek :: Ptr Word8 -> IO Word8 Source #

poke :: Ptr Word8 -> Word8 -> IO () Source #

Ix Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods range :: (Word8, Word8) -> [Word8] Source # index :: (Word8, Word8) -> Word8 -> Int Source # unsafeIndex :: (Word8, Word8) -> Word8 -> Int Source # inRange :: (Word8, Word8) -> Word8 -> Bool Source # rangeSize :: (Word8, Word8) -> Int Source # unsafeRangeSize :: (Word8, Word8) -> Int Source #
Num Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (+) :: Word8 -> Word8 -> Word8 Source # (-) :: Word8 -> Word8 -> Word8 Source # (*) :: Word8 -> Word8 -> Word8 Source # negate :: Word8 -> Word8 Source # abs :: Word8 -> Word8 Source # signum :: Word8 -> Word8 Source # fromInteger :: Integer -> Word8 Source #
Integral Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods quot :: Word8 -> Word8 -> Word8 Source # rem :: Word8 -> Word8 -> Word8 Source # div :: Word8 -> Word8 -> Word8 Source # mod :: Word8 -> Word8 -> Word8 Source # quotRem :: Word8 -> Word8 -> (Word8, Word8) Source # divMod :: Word8 -> Word8 -> (Word8, Word8) Source # toInteger :: Word8 -> Integer Source #
Real Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods toRational :: Word8 -> Rational Source #
Show Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods showsPrec :: Int -> Word8 -> ShowS Source # show :: Word8 -> String Source # showList :: [Word8] -> ShowS Source #
Eq Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (==) :: Word8 -> Word8 -> Bool Source # (/=) :: Word8 -> Word8 -> Bool Source #
Ord Word8 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods compare :: Word8 -> Word8 -> Ordering Source # (<) :: Word8 -> Word8 -> Bool Source # (<=) :: Word8 -> Word8 -> Bool Source # (>) :: Word8 -> Word8 -> Bool Source # (>=) :: Word8 -> Word8 -> Bool Source # max :: Word8 -> Word8 -> Word8 Source # min :: Word8 -> Word8 -> Word8 Source #

data Word16 Source #

16-bit unsigned integer type

#### Instances

Instances details

PrintfArg Word16 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word16 -> FieldFormatter Source # parseFormat :: Word16 -> ModifierParser Source #
Bits Word16 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(.&.) :: Word16 -> Word16 -> Word16 Source #

(.|.) :: Word16 -> Word16 -> Word16 Source #

xor :: Word16 -> Word16 -> Word16 Source #

complement :: Word16 -> Word16 Source #

shift :: Word16 -> Int -> Word16 Source #

rotate :: Word16 -> Int -> Word16 Source #

zeroBits :: Word16 Source #

bit :: Int -> Word16 Source #

setBit :: Word16 -> Int -> Word16 Source #

clearBit :: Word16 -> Int -> Word16 Source #

complementBit :: Word16 -> Int -> Word16 Source #

testBit :: Word16 -> Int -> Bool Source #

bitSizeMaybe :: Word16 -> Maybe Int Source #

bitSize :: Word16 -> Int Source #

isSigned :: Word16 -> Bool Source #

shiftL :: Word16 -> Int -> Word16 Source #

unsafeShiftL :: Word16 -> Int -> Word16 Source #

shiftR :: Word16 -> Int -> Word16 Source #

unsafeShiftR :: Word16 -> Int -> Word16 Source #

rotateL :: Word16 -> Int -> Word16 Source #

rotateR :: Word16 -> Int -> Word16 Source #

popCount :: Word16 -> Int Source #

FiniteBits Word16 | Since: base-4.6.0.0
Instance details Defined in GHC.Internal.Word Methods finiteBitSize :: Word16 -> Int Source # countLeadingZeros :: Word16 -> Int Source # countTrailingZeros :: Word16 -> Int Source #
Bounded Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods minBound :: Word16 Source # maxBound :: Word16 Source #
Enum Word16 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

succ :: Word16 -> Word16 Source #

pred :: Word16 -> Word16 Source #

toEnum :: Int -> Word16 Source #

fromEnum :: Word16 -> Int Source #

enumFrom :: Word16 -> [Word16] Source #

enumFromThen :: Word16 -> Word16 -> [Word16] Source #

enumFromTo :: Word16 -> Word16 -> [Word16] Source #

enumFromThenTo :: Word16 -> Word16 -> Word16 -> [Word16] Source #

Storable Word16 | Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Word16 -> Int Source #

alignment :: Word16 -> Int Source #

peekElemOff :: Ptr Word16 -> Int -> IO Word16 Source #

pokeElemOff :: Ptr Word16 -> Int -> Word16 -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Word16 Source #

pokeByteOff :: Ptr b -> Int -> Word16 -> IO () Source #

peek :: Ptr Word16 -> IO Word16 Source #

poke :: Ptr Word16 -> Word16 -> IO () Source #

Ix Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods range :: (Word16, Word16) -> [Word16] Source # index :: (Word16, Word16) -> Word16 -> Int Source # unsafeIndex :: (Word16, Word16) -> Word16 -> Int Source # inRange :: (Word16, Word16) -> Word16 -> Bool Source # rangeSize :: (Word16, Word16) -> Int Source # unsafeRangeSize :: (Word16, Word16) -> Int Source #
Num Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (+) :: Word16 -> Word16 -> Word16 Source # (-) :: Word16 -> Word16 -> Word16 Source # (*) :: Word16 -> Word16 -> Word16 Source # negate :: Word16 -> Word16 Source # abs :: Word16 -> Word16 Source # signum :: Word16 -> Word16 Source # fromInteger :: Integer -> Word16 Source #
Integral Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods quot :: Word16 -> Word16 -> Word16 Source # rem :: Word16 -> Word16 -> Word16 Source # div :: Word16 -> Word16 -> Word16 Source # mod :: Word16 -> Word16 -> Word16 Source # quotRem :: Word16 -> Word16 -> (Word16, Word16) Source # divMod :: Word16 -> Word16 -> (Word16, Word16) Source # toInteger :: Word16 -> Integer Source #
Real Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods toRational :: Word16 -> Rational Source #
Show Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods showsPrec :: Int -> Word16 -> ShowS Source # show :: Word16 -> String Source # showList :: [Word16] -> ShowS Source #
Eq Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (==) :: Word16 -> Word16 -> Bool Source # (/=) :: Word16 -> Word16 -> Bool Source #
Ord Word16 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods compare :: Word16 -> Word16 -> Ordering Source # (<) :: Word16 -> Word16 -> Bool Source # (<=) :: Word16 -> Word16 -> Bool Source # (>) :: Word16 -> Word16 -> Bool Source # (>=) :: Word16 -> Word16 -> Bool Source # max :: Word16 -> Word16 -> Word16 Source # min :: Word16 -> Word16 -> Word16 Source #

data Word32 Source #

32-bit unsigned integer type

#### Instances

Instances details

PrintfArg Word32 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word32 -> FieldFormatter Source # parseFormat :: Word32 -> ModifierParser Source #
Bits Word32 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(.&.) :: Word32 -> Word32 -> Word32 Source #

(.|.) :: Word32 -> Word32 -> Word32 Source #

xor :: Word32 -> Word32 -> Word32 Source #

complement :: Word32 -> Word32 Source #

shift :: Word32 -> Int -> Word32 Source #

rotate :: Word32 -> Int -> Word32 Source #

zeroBits :: Word32 Source #

bit :: Int -> Word32 Source #

setBit :: Word32 -> Int -> Word32 Source #

clearBit :: Word32 -> Int -> Word32 Source #

complementBit :: Word32 -> Int -> Word32 Source #

testBit :: Word32 -> Int -> Bool Source #

bitSizeMaybe :: Word32 -> Maybe Int Source #

bitSize :: Word32 -> Int Source #

isSigned :: Word32 -> Bool Source #

shiftL :: Word32 -> Int -> Word32 Source #

unsafeShiftL :: Word32 -> Int -> Word32 Source #

shiftR :: Word32 -> Int -> Word32 Source #

unsafeShiftR :: Word32 -> Int -> Word32 Source #

rotateL :: Word32 -> Int -> Word32 Source #

rotateR :: Word32 -> Int -> Word32 Source #

popCount :: Word32 -> Int Source #

FiniteBits Word32 | Since: base-4.6.0.0
Instance details Defined in GHC.Internal.Word Methods finiteBitSize :: Word32 -> Int Source # countLeadingZeros :: Word32 -> Int Source # countTrailingZeros :: Word32 -> Int Source #
Bounded Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods minBound :: Word32 Source # maxBound :: Word32 Source #
Enum Word32 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

succ :: Word32 -> Word32 Source #

pred :: Word32 -> Word32 Source #

toEnum :: Int -> Word32 Source #

fromEnum :: Word32 -> Int Source #

enumFrom :: Word32 -> [Word32] Source #

enumFromThen :: Word32 -> Word32 -> [Word32] Source #

enumFromTo :: Word32 -> Word32 -> [Word32] Source #

enumFromThenTo :: Word32 -> Word32 -> Word32 -> [Word32] Source #

Storable Word32 | Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Word32 -> Int Source #

alignment :: Word32 -> Int Source #

peekElemOff :: Ptr Word32 -> Int -> IO Word32 Source #

pokeElemOff :: Ptr Word32 -> Int -> Word32 -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Word32 Source #

pokeByteOff :: Ptr b -> Int -> Word32 -> IO () Source #

peek :: Ptr Word32 -> IO Word32 Source #

poke :: Ptr Word32 -> Word32 -> IO () Source #

Ix Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods range :: (Word32, Word32) -> [Word32] Source # index :: (Word32, Word32) -> Word32 -> Int Source # unsafeIndex :: (Word32, Word32) -> Word32 -> Int Source # inRange :: (Word32, Word32) -> Word32 -> Bool Source # rangeSize :: (Word32, Word32) -> Int Source # unsafeRangeSize :: (Word32, Word32) -> Int Source #
Num Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (+) :: Word32 -> Word32 -> Word32 Source # (-) :: Word32 -> Word32 -> Word32 Source # (*) :: Word32 -> Word32 -> Word32 Source # negate :: Word32 -> Word32 Source # abs :: Word32 -> Word32 Source # signum :: Word32 -> Word32 Source # fromInteger :: Integer -> Word32 Source #
Integral Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods quot :: Word32 -> Word32 -> Word32 Source # rem :: Word32 -> Word32 -> Word32 Source # div :: Word32 -> Word32 -> Word32 Source # mod :: Word32 -> Word32 -> Word32 Source # quotRem :: Word32 -> Word32 -> (Word32, Word32) Source # divMod :: Word32 -> Word32 -> (Word32, Word32) Source # toInteger :: Word32 -> Integer Source #
Real Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods toRational :: Word32 -> Rational Source #
Show Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods showsPrec :: Int -> Word32 -> ShowS Source # show :: Word32 -> String Source # showList :: [Word32] -> ShowS Source #
Eq Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (==) :: Word32 -> Word32 -> Bool Source # (/=) :: Word32 -> Word32 -> Bool Source #
Ord Word32 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods compare :: Word32 -> Word32 -> Ordering Source # (<) :: Word32 -> Word32 -> Bool Source # (<=) :: Word32 -> Word32 -> Bool Source # (>) :: Word32 -> Word32 -> Bool Source # (>=) :: Word32 -> Word32 -> Bool Source # max :: Word32 -> Word32 -> Word32 Source # min :: Word32 -> Word32 -> Word32 Source #

data Word64 Source #

64-bit unsigned integer type

#### Instances

Instances details

PrintfArg Word64 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word64 -> FieldFormatter Source # parseFormat :: Word64 -> ModifierParser Source #
Bits Word64 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(.&.) :: Word64 -> Word64 -> Word64 Source #

(.|.) :: Word64 -> Word64 -> Word64 Source #

xor :: Word64 -> Word64 -> Word64 Source #

complement :: Word64 -> Word64 Source #

shift :: Word64 -> Int -> Word64 Source #

rotate :: Word64 -> Int -> Word64 Source #

zeroBits :: Word64 Source #

bit :: Int -> Word64 Source #

setBit :: Word64 -> Int -> Word64 Source #

clearBit :: Word64 -> Int -> Word64 Source #

complementBit :: Word64 -> Int -> Word64 Source #

testBit :: Word64 -> Int -> Bool Source #

bitSizeMaybe :: Word64 -> Maybe Int Source #

bitSize :: Word64 -> Int Source #

isSigned :: Word64 -> Bool Source #

shiftL :: Word64 -> Int -> Word64 Source #

unsafeShiftL :: Word64 -> Int -> Word64 Source #

shiftR :: Word64 -> Int -> Word64 Source #

unsafeShiftR :: Word64 -> Int -> Word64 Source #

rotateL :: Word64 -> Int -> Word64 Source #

rotateR :: Word64 -> Int -> Word64 Source #

popCount :: Word64 -> Int Source #

FiniteBits Word64 | Since: base-4.6.0.0
Instance details Defined in GHC.Internal.Word Methods finiteBitSize :: Word64 -> Int Source # countLeadingZeros :: Word64 -> Int Source # countTrailingZeros :: Word64 -> Int Source #
Bounded Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods minBound :: Word64 Source # maxBound :: Word64 Source #
Enum Word64 | Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

succ :: Word64 -> Word64 Source #

pred :: Word64 -> Word64 Source #

toEnum :: Int -> Word64 Source #

fromEnum :: Word64 -> Int Source #

enumFrom :: Word64 -> [Word64] Source #

enumFromThen :: Word64 -> Word64 -> [Word64] Source #

enumFromTo :: Word64 -> Word64 -> [Word64] Source #

enumFromThenTo :: Word64 -> Word64 -> Word64 -> [Word64] Source #

Storable Word64 | Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Word64 -> Int Source #

alignment :: Word64 -> Int Source #

peekElemOff :: Ptr Word64 -> Int -> IO Word64 Source #

pokeElemOff :: Ptr Word64 -> Int -> Word64 -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Word64 Source #

pokeByteOff :: Ptr b -> Int -> Word64 -> IO () Source #

peek :: Ptr Word64 -> IO Word64 Source #

poke :: Ptr Word64 -> Word64 -> IO () Source #

Ix Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods range :: (Word64, Word64) -> [Word64] Source # index :: (Word64, Word64) -> Word64 -> Int Source # unsafeIndex :: (Word64, Word64) -> Word64 -> Int Source # inRange :: (Word64, Word64) -> Word64 -> Bool Source # rangeSize :: (Word64, Word64) -> Int Source # unsafeRangeSize :: (Word64, Word64) -> Int Source #
Num Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (+) :: Word64 -> Word64 -> Word64 Source # (-) :: Word64 -> Word64 -> Word64 Source # (*) :: Word64 -> Word64 -> Word64 Source # negate :: Word64 -> Word64 Source # abs :: Word64 -> Word64 Source # signum :: Word64 -> Word64 Source # fromInteger :: Integer -> Word64 Source #
Integral Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods quot :: Word64 -> Word64 -> Word64 Source # rem :: Word64 -> Word64 -> Word64 Source # div :: Word64 -> Word64 -> Word64 Source # mod :: Word64 -> Word64 -> Word64 Source # quotRem :: Word64 -> Word64 -> (Word64, Word64) Source # divMod :: Word64 -> Word64 -> (Word64, Word64) Source # toInteger :: Word64 -> Integer Source #
Real Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods toRational :: Word64 -> Rational Source #
Show Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods showsPrec :: Int -> Word64 -> ShowS Source # show :: Word64 -> String Source # showList :: [Word64] -> ShowS Source #
Eq Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods (==) :: Word64 -> Word64 -> Bool Source # (/=) :: Word64 -> Word64 -> Bool Source #
Ord Word64 | Since: base-2.1
Instance details Defined in GHC.Internal.Word Methods compare :: Word64 -> Word64 -> Ordering Source # (<) :: Word64 -> Word64 -> Bool Source # (<=) :: Word64 -> Word64 -> Bool Source # (>) :: Word64 -> Word64 -> Bool Source # (>=) :: Word64 -> Word64 -> Bool Source # max :: Word64 -> Word64 -> Word64 Source # min :: Word64 -> Word64 -> Word64 Source #

data ByteString Source #

A space-efficient representation of a `Word8` vector, supporting many efficient operations.

A `ByteString` contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.

#### Instances

Instances details

NFData ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods rnf :: ByteString -> () Source #
Monoid ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods mempty :: ByteString Source # mappend :: ByteString -> ByteString -> ByteString Source # mconcat :: [ByteString] -> ByteString Source #
Semigroup ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods (<>) :: ByteString -> ByteString -> ByteString Source # sconcat :: NonEmpty ByteString -> ByteString Source # stimes :: Integral b => b -> ByteString -> ByteString Source #
Data ByteString |

Instance details

Defined in Data.ByteString.Internal.Type

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteString -> c ByteString Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteString Source #

toConstr :: ByteString -> Constr Source #

dataTypeOf :: ByteString -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ByteString) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteString) Source #

gmapT :: (forall b. Data b => b -> b) -> ByteString -> ByteString Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ByteString -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteString -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

IsString ByteString | Beware: `fromString` truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�
Instance details Defined in Data.ByteString.Internal.Type Methods fromString :: String -> ByteString Source #
IsList ByteString | Since: bytestring-0.10.12.0

Instance details

Defined in Data.ByteString.Internal.Type

Associated Types

type Item ByteString |
Instance details Defined in Data.ByteString.Internal.Type type Item ByteString = Word8

Methods

fromList :: [Item ByteString] -> ByteString Source #

fromListN :: Int -> [Item ByteString] -> ByteString Source #

toList :: ByteString -> [Item ByteString] Source #

Read ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods readsPrec :: Int -> ReadS ByteString Source # readList :: ReadS [ByteString] Source # readPrec :: ReadPrec ByteString Source # readListPrec :: ReadPrec [ByteString] Source #
Show ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods showsPrec :: Int -> ByteString -> ShowS Source # show :: ByteString -> String Source # showList :: [ByteString] -> ShowS Source #
Eq ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods (==) :: ByteString -> ByteString -> Bool Source # (/=) :: ByteString -> ByteString -> Bool Source #
Ord ByteString |

Instance details

Defined in Data.ByteString.Internal.Type

Methods

compare :: ByteString -> ByteString -> Ordering Source #

(<) :: ByteString -> ByteString -> Bool Source #

(<=) :: ByteString -> ByteString -> Bool Source #

(>) :: ByteString -> ByteString -> Bool Source #

(>=) :: ByteString -> ByteString -> Bool Source #

max :: ByteString -> ByteString -> ByteString Source #

min :: ByteString -> ByteString -> ByteString Source #

Lift ByteString | Since: bytestring-0.11.2.0
Instance details Defined in Data.ByteString.Internal.Type Methods lift :: Quote m => ByteString -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ByteString -> Code m ByteString Source #
type Item ByteString |
Instance details Defined in Data.ByteString.Internal.Type type Item ByteString = Word8