byteable-0.1.1: Type class for sequence of bytes

Portabilitygood
Stabilityexperimental
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellNone

Data.Byteable

Description

 

Synopsis

Documentation

class Byteable a whereSource

Class of things that can generate sequence of bytes

Methods

toBytes :: a -> ByteStringSource

Convert a byteable type to a bytestring

byteableLength :: a -> IntSource

Return the size of the byteable .

withBytePtr :: a -> (Ptr Word8 -> IO b) -> IO bSource

Provide a way to look at the data of a byteable type with a ptr.

Instances

constEqBytes :: Byteable a => a -> a -> BoolSource

A constant time equality test for 2 byteable objects.

If objects are of 2 different sizes, the function will abort early without comparing any bytes.

compared to == , this function will go over all the bytes present before yielding a result even when knowing the overall result early in the processing.