Library/AltBinary: Difference between revisions

From HaskellWiki
No edit summary
 
No edit summary
Line 6: Line 6:
- (de)serialization speed of 20-60 mb/sec on 1GHz CPU
- (de)serialization speed of 20-60 mb/sec on 1GHz CPU
- free intermixing of text and binary i/o on the same Stream
- free intermixing of text and binary i/o on the same Stream
- support for byte-aligned and bit-aligned, low-endian and big-endian
- support for byte-aligned and bit-aligned, low-endian and big-endian serialization using the same interface
    serialization using the same interface
- classical Binary class with "get" and "put_" functions defines default representation for each type
- classical Binary class with "get" and "put_" functions defines
- get/put_ uses fixed-size encoding for Int8..Word64, but variable-length encoding for Int/Word/Integer (including encoding of array bounds and list lengths)
    default representation for each type
- any integral value can be saved with explicitly specified size using functions "putBits bh bits value" and "getBits bh bits" (their shortcuts putBit/putWord8...putWord64/getBit/... is also supported for all integral types)
- get/put_ uses fixed-size encoding for Int8..Word64, but variable-length encoding
    for Int/Word/Integer (including encoding of array bounds and list lengths)
- any integral value can be saved with explicitly specified size using
    functions "putBits bh bits value" and "getBits bh bits" (their shortcuts
    putBit/putWord8...putWord64/getBit/... is also supported for all integral types)
- get/put_ uses UTF8 encoding for strings/chars
- get/put_ uses UTF8 encoding for strings/chars
- Binary class instances (i.e. get/put_ implementation) for Bounded Enum,
- Binary class instances (i.e. get/put_ implementation) for Bounded Enum, Storable, arrays, maps and sets
    Storable, arrays, maps and sets
- lots of alternative representations for Strings, lists and arrays, including ability to use user-supported function to read/write each list/array element, such as "putMArrayWith (putBits 15) h arr". for example, "putString0With putLatin1Char h s" implements ASCIIZ string encoding
- lots of alternative representations for Strings, lists and arrays,
    including ability to use user-supported function to read/write
    each list/array element, such as "putMArrayWith (putBits 15) h arr".
    for example, "putString0With putLatin1Char h s" implements
    ASCIIZ string encoding
- Template Haskell can used to automatically derive new Binary instances
- Template Haskell can used to automatically derive new Binary instances
- ability to serialize data to any Stream, including Handle, raw
- ability to serialize data to any Stream, including Handle, raw files, memory-mapped files, memory and string buffers, pipes, network sockets and so on
    files, memory-mapped files, memory and string buffers, pipes,
- after all, it can work in any monad. the only thing required for it's work is something supporting ByteStream interface, i.e. implementing vGetByte and vPutByte operations in some monad
    network sockets and so on
- after all, it can work in any monad. the only thing required for
    it's work is something supporting ByteStream interface, i.e.
    implementing vGetByte and vPutByte operations in some monad


... and i still don't mentioned some features such as (encode :: a->String)
... and i still don't mentioned some features such as (encode :: a->String) and decode functions. i think that i implemented in this lib everything that anyone (except for Einar ;)) ever imagined :)
and decode functions. i think that i implemented in this lib
everything that anyone (except for Einar ;)) ever imagined :)

Revision as of 08:48, 12 May 2006

AltBinary is a part of Streams library, what implements binary I/O and serialization faсilities. Just a list of features implemented in this lib:

- class-based AltBinary interface plus emulation of NewBinary library interface - compatibility with Hugs and GHC, with GHC-specific speed optimizations - (de)serialization speed of 20-60 mb/sec on 1GHz CPU - free intermixing of text and binary i/o on the same Stream - support for byte-aligned and bit-aligned, low-endian and big-endian serialization using the same interface - classical Binary class with "get" and "put_" functions defines default representation for each type - get/put_ uses fixed-size encoding for Int8..Word64, but variable-length encoding for Int/Word/Integer (including encoding of array bounds and list lengths) - any integral value can be saved with explicitly specified size using functions "putBits bh bits value" and "getBits bh bits" (their shortcuts putBit/putWord8...putWord64/getBit/... is also supported for all integral types) - get/put_ uses UTF8 encoding for strings/chars - Binary class instances (i.e. get/put_ implementation) for Bounded Enum, Storable, arrays, maps and sets - lots of alternative representations for Strings, lists and arrays, including ability to use user-supported function to read/write each list/array element, such as "putMArrayWith (putBits 15) h arr". for example, "putString0With putLatin1Char h s" implements ASCIIZ string encoding - Template Haskell can used to automatically derive new Binary instances - ability to serialize data to any Stream, including Handle, raw files, memory-mapped files, memory and string buffers, pipes, network sockets and so on - after all, it can work in any monad. the only thing required for it's work is something supporting ByteStream interface, i.e. implementing vGetByte and vPutByte operations in some monad

... and i still don't mentioned some features such as (encode :: a->String) and decode functions. i think that i implemented in this lib everything that anyone (except for Einar ;)) ever imagined :)