| Copyright | (c) Duncan Coutts 2015-2017 |
|---|---|
| License | BSD3-style (see LICENSE.txt) |
| Maintainer | duncan@community.haskell.org |
| Stability | experimental |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | Haskell2010 |
Codec.CBOR.Magic
Contents
Description
An internal module for doing magical, low-level, and unholy things in the name of efficiency.
- grabWord8 :: Ptr () -> Word
- grabWord16 :: Ptr () -> Word
- grabWord32 :: Ptr () -> Word
- grabWord64 :: Ptr () -> Word64
- eatTailWord8 :: ByteString -> Word
- eatTailWord16 :: ByteString -> Word
- eatTailWord32 :: ByteString -> Word
- eatTailWord64 :: ByteString -> Word64
- wordToFloat16 :: Word -> Float
- floatToWord16 :: Float -> Word16
- wordToFloat32 :: Word -> Float
- wordToFloat64 :: Word64 -> Double
- nintegerFromBytes :: ByteString -> Integer
- uintegerFromBytes :: ByteString -> Integer
- data Counter s
- newCounter :: Int -> ST s (Counter s)
- readCounter :: Counter s -> ST s Int
- writeCounter :: Counter s -> Int -> ST s ()
- incCounter :: Counter s -> ST s ()
- decCounter :: Counter s -> ST s ()
- copyByteStringToByteArray :: ByteString -> ByteArray
- copyByteArrayToByteString :: ByteArray -> Int -> Int -> ByteString
Word utilities
ByteString utilities
ByteStringeatTailWord8 :: ByteString -> Word Source #
Take the tail of a (i.e. drop the first byte) and read the
resulting byte(s) as an 8-bit word value. The input ByteString MUST be at
least 2 bytes long: one byte to drop from the front, and one to read as a
ByteString value. This is not checked, and failure to ensure this will result
in undefined behavior.Word
eatTailWord16 :: ByteString -> Word Source #
Take the tail of a (i.e. drop the first byte) and read the
resulting byte(s) as a 16-bit word value. The input ByteString MUST be at
least 3 bytes long: one byte to drop from the front, and two to read as a
16-bit ByteString value. This is not checked, and failure to ensure this will
result in undefined behavior.Word
eatTailWord32 :: ByteString -> Word Source #
Take the tail of a (i.e. drop the first byte) and read the
resulting byte(s) as a 32-bit word value. The input ByteString MUST be at
least 5 bytes long: one byte to drop from the front, and four to read as a
32-bit ByteString value. This is not checked, and failure to ensure this will
result in undefined behavior.Word
eatTailWord64 :: ByteString -> Word64 Source #
Take the tail of a (i.e. drop the first byte) and read the
resulting byte(s) as a 64-bit word value. The input ByteString MUST be at
least 9 bytes long: one byte to drop from the front, and eight to read as a
64-bit ByteString value. This is not checked, and failure to ensure this will
result in undefined behavior.Word64
Half-floats
Float/Word conversion
Integer utilities
IntegernintegerFromBytes :: ByteString -> Integer Source #
Create a negative out of a raw Integer.ByteString
uintegerFromBytes :: ByteString -> Integer Source #
Create an out of a raw Integer.ByteString
Simple mutable counters
An efficient, mutable counter. Designed to be used inside
or other primitive monads, hence it carries an abstract
rank-2 STs type parameter.
Array support
copyByteStringToByteArray :: ByteString -> ByteArray Source #
Copy a and create a primitive ByteString from it.ByteArray
copyByteArrayToByteString Source #
Arguments
| :: ByteArray |
|
| -> Int | Offset into the |
| -> Int | Length of the data to copy. |
| -> ByteString |
Copy a at a certain offset and length into a
ByteArray.ByteString