The bind-marshal package

[Tags: bsd3, library]

A (in development) high performance data marshaling layer for haskell. Uses a pair of parameterized monads to represent: Data marshalling actions with static buffering requirements (EG: Needs no more than 100 bytes available to succeed) ; Data marshalling actions that are a dynamic composition of actions with static buffering requirements.


[Skip to ReadMe]

Properties

Version0.1
Change logNone available
Dependenciesbase (==4.4.*), bytestring (==0.9.*), containers (==0.4.*), deepseq (==1.1.*), ghc-prim, monads-tf (==0.1.*), mtl (==2.0.*), numeric-prelude (==0.2.*), random (==1.0.*), stm (==2.2.*), strict (==0.3.*), transformers (==0.2.*), type-level-tf (>=0.2.1), unix (==2.5.*) [details]
LicenseBSD3
AuthorCorey O'Connor <coreyoconnor@gmail.com>
MaintainerCorey O'Connor <coreyoconnor@gmail.com>
CategoryData
Home pagehttps://github.com/coreyoconnor/bind-marshal
Source repositoryhead: git clone git://github.com/coreyoconnor/bind-marshal.git
UploadedSun Oct 30 17:05:44 UTC 2011 by CoreyOConnor
DistributionsNixOS:0.1
Downloads244 total (6 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for bind-marshal-0.1

bind-marshal

A (in development) high performance data marshaling layer for haskell. Uses a pair of parameterized
monads to represent: Data marshalling actions with static buffering requirements (EG: Needs no more
than 100 bytes available to succeed) ; Data marshalling actions with a dynamic composition of
actions with static buffering requirements.

Currently bind-marshal can only be used via dev-system. A build/run/test dev tool I have not
currently released. Sorry!

The static buffering actions parameterize a monad with the maximum number of bytes that will either
be read/written from/to a buffer. A type level number is used to represent the maximum number of
bytes. 

For example, this expression represents a serialization action that writes at most 8 bytes in host
endian order:

foo :: StaticSerAction D8 () -- D8 is the type level representation of 8
foo = do
    ser (256 :: Word32) -- ser for serialize
    ser (13 :: Word32)
    static_return ()

A more complex example would be:
bar :: StaticSerAction D16 ()
bar = do
    _ <- foo
    _ <- foo
    static_return ()

A note on syntax: The "static_return" is equivalent to "return" except it plays nicely with the
mechanism that infers the buffer requirements. Actually, due to the use of parameterized monads
"return" cannot be used. Instead "returnM" must be used which properly interacts with the
parameterized monad machinery. So a more accurate statement would be that "static_return" is
equivalent to "returnM".

Static actions are useful for basic structures. However, most structures contain components whose
marshalled size are dynamic; Not known at compile time. 

Bind-marshal represents these cases with the the Dynamic actions: DynamicSerAction,
DynamicDesAction. Which are actions composed of individual static actions. Where before each static
action is a check that assures the buffer satisfies the requirements of the static action. 

For example, the following action:

pew i = do 
    replicateM i $ dyn_action $ do      
        x :: Word32 <- des              
        y :: Word32 <- des              
        static_return ()

Is evaluated (more or less) like so:
    0. For i times
        a. Verify there is at least 8 bytes available to read
        b. Read 4 bytes
        c. Read 4 bytes


Currently a "dyn_action" is required to "lift" a static action into a dynamic action monad. This
should be automatic, but I have thus failed to get automatic lifting to work as a user expects. In
the currently implementation: If the dyn_action is ommited the equation will fail to type check.