Modulecborg-0.2.10.0Haskell2010
Codec.CBOR.Magic
An internal module for doing magical, low-level, and unholy things in the name of efficiency.
- 1 type
- 33 values
- Packagecborg-0.2.10.0
- Exports34
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceMagic.hs
Word utilities
4 declarationsByteString utilities
4 declarationsTake the tail of a ByteString (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 Word value. This is not checked, and failure to ensure this will result in undefined behavior.
Take the tail of a ByteString (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 Word value. This is not checked, and failure to ensure this will result in undefined behavior.
Take the tail of a ByteString (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 Word value. This is not checked, and failure to ensure this will result in undefined behavior.
Take the tail of a ByteString (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 Word64 value. This is not checked, and failure to ensure this will result in undefined behavior.
Half-floats
2 declarationsFloat/Word conversion
2 declarationsInt and Word explicit conversions
12 declarationsInteger utilities
2 declarationsCreate a negative Integer out of a raw ByteString.
Create an Integer out of a raw ByteString.
Simple mutable counters
6 declarationsAn efficient, mutable counter. Designed to be used inside
ST or other primitive monads, hence it carries an abstract
rank-2 s type parameter.
Create a new counter with a starting Int value.
Read the current value of a Counter.
Write a new value into the Counter.
Increment a Counter by one.
Decrement a Counter by one.
Array support
2 declarationsCopy a ByteString and create a primitive ByteArray from it.
Copy a ByteArray at a certain offset and length into a ByteString.