Here's an example with Data.Binary:
import Data.Binary
import Control.Monad
import Codec.Compression.GZi
instance Binary Exp where
put (IntE i) = do put (0 :: Word8)
put i
put (OpE s e1 e2) = do put (1 :: Word8)
put s
put e1
put e2
get = do t <- get :: Get Word8
case t of
0 -> do i <- get
return (IntE i)
1 -> do s <- get
e1 <- get
e2 <- get
return (OpE s e1 e2)
You can get all the information about Haskell's put/get monads, some sample
code for binary serialization (encode/decode) here:
http://www.cse.unsw.edu.au/~dons/binary/Data-Binary.html
If you want to be on the bleeding edge, you might want to check out
Happs (Haskell Application Server):
http://happs.org/
Cheers,
Zubin.
On Thu, Jul 17, 2008 at 8:44 AM, Saifi Khan <[EMAIL PROTECTED]>
wrote:
> On Thu, 17 Jul 2008, Zubin Wadia wrote:
>
> >
> > You could use Data.Binary and it would be native and even quicker,
> >
>
> Zubin, Could you please share how to write bit extraction code
> using Data.Binary in Haskell ?
>
> Two areas i am looking into very closely are X.509 and packet processing.
>
> Thank you in advance.
>
> thanks
> Saifi.
>