[Haskell-cafe] Data.Binary and little endian encoding

David Leimbach leimy2k at gmail.com
Wed May 27 23:52:56 EDT 2009

Sorry took so long to get back... Thank you for the response.  Been really
busy lately :-)

On Sat, May 16, 2009 at 3:46 AM, Khudyakov Alexey <alexey.skladnoy at gmail.com
> wrote:

> On Friday 15 May 2009 06:52:29 David Leimbach wrote:
> > I actually need little endian encoding... wondering if anyone else hit
> this
> > with Data.Binary. (because I'm working with Bell Lab's 9P protocol which
> > does encode things on the network in little-endian order).
> > Anyone got some "tricks" for this?
> >
> > Dave
> You could just define data type and Binary instance for 9P messages.
> Something
> like this:
> P9Message = Tversion { tag :: Word16, msize :: Word32, version :: String }
>    | ...
> instance Binary P9Message where
>  put (Tverstion  t m v) =  putWord16le t >>  putWord32le m >> put v
>  -- and so on...
>  get = do
>    length <- getWord32le
>    id <- getWord16le
>    case is of
>      p9TMessage -> do ...
> There are a lot of boilerplate code thought...

Thank you, this still looks like a useful way to proceed, combined with the
BinaryLE approach perhaps, to avoid a lot of boilerplate.

> BTW could you say what do you want to do with 9P? I tried to play with it
> using libixp library but without any success. It was mainly to understand
> how
> does it works and how can it be used.

>From a services point of view, 9P gives you a way to host them, and even
devices, on a network share that can be "mounted" into the filesystem's
namespace.  The net result is you've plugged into the standard unix
utilities that do open, read, write etc, and can do a lot of interesting
things with mere shell scripts.

Operating systems that can be clients of a 9P service include Linux,
Inferno, Plan 9, and anything else that runs FUSE 9P (several BSDs).

>From a client perspective, having a 9P implementation gives you a more
fine-grained programatic interface to accessing other 9P services.

There are also a lot of 9P implementations in many languages that you can
interoperate with:


> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090527/e7a49475/attachment.html

More information about the Haskell-Cafe mailing list