Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 37 lines (31 sloc) 0.926 kB
e9eefaa @mariusae Haskell implementation of BERT.
authored
1 -- |
2 -- Module : Data.BERT.Packet
3 -- Copyright : (c) marius a. eriksen 2009
4 --
5 -- License : BSD3
6 -- Maintainer : marius@monkey.org
7 -- Stability : experimental
8 -- Portability : GHC
9 --
10 -- BERP support.
11 module Data.BERT.Packet
12 ( Packet(..)
13 ) where
14
15 import Control.Monad (liftM)
16 import Data.ByteString (ByteString)
17 import Data.ByteString.Lazy as B
18 import Data.Binary (Binary(..), encode, decode)
19 import Data.Binary.Put (putWord32be, putLazyByteString)
20 import Data.Binary.Get (getWord32be, getLazyByteString)
21
22 import Data.BERT.Term (Term(..))
23
24 data Packet
25 = Packet Term
26 deriving (Show, Ord, Eq)
27
28 instance Binary Packet where
29 put (Packet term) =
30 putWord32be (fromIntegral len) >> putLazyByteString encoded
31 where encoded = encode term
32 len = B.length encoded
33 get = liftM fromIntegral getWord32be >>=
34 getLazyByteString >>=
35 return . Packet . decode
36
Something went wrong with that request. Please try again.