RE: [Haskell-cafe] Haskell poker server

2005-09-13 Thread Simon Marlow
On 28 August 2005 20:00, Joel Reymont wrote: > I get a message from Erlang once data arrives over TCP and the > message is a {tcp, Socket, Bin} tuple where Bin is binary data. I can > easily extract what I need using Erlang binary pattern matching: > > read(<<24, GID:32, Seq:16>>) -> > {24,

Re: [Haskell-cafe] Haskell poker server

2005-08-31 Thread Tomasz Zielonka
On Tue, Aug 30, 2005 at 01:31:22PM +0200, Joel Reymont wrote: > Can I beg for examples? This is from some old code, slightly polished for presentation - the code for parsing DNS domain name label in DNS packets: parseLabel :: CharParser st Label parseLabel = ( "label") $ do len <-

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread John Meacham
On Tue, Aug 30, 2005 at 12:35:30PM +0100, Philippa Cowderoy wrote: > On Tue, 30 Aug 2005, Tomasz Zielonka wrote: > > >On Tue, Aug 30, 2005 at 12:41:20PM +0200, Joel Reymont wrote: > >>Erlang does this nicely, I replied to the LtU thread. I positively > >>got the impression that nobody was parsing

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread John Meacham
On Mon, Aug 29, 2005 at 01:08:31AM +0200, Joel Reymont wrote: > Alistair, > > Thanks alot for your examples. I still have one unanswered question... > > How would you read a tuple of values (24, GID, Seq) like in my Erlang > example, where 24 is one byte, GID is a 4-byte integer and Seq is a 2-

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Miles Sabin
Joel Reymont wrote, > Can I beg for examples? I've been using parsec for binary parsing (Java class files in my case) as a first exercise with both Haskell and combinator parsing, with a view to applying same to network protocols. The experience has been surprisingly pleasant. In particular, it

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Philippa Cowderoy
On Tue, 30 Aug 2005, Tomasz Zielonka wrote: On Tue, Aug 30, 2005 at 12:41:20PM +0200, Joel Reymont wrote: Erlang does this nicely, I replied to the LtU thread. I positively got the impression that nobody was parsing binary data in Haskell ;). I am doing this quite often, I apologize for not s

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Joel Reymont
Can I beg for examples? On Aug 30, 2005, at 1:29 PM, Tomasz Zielonka wrote: BTW, if efficiency is not a primary concern, Parsec can be quite nice for decoding binary messages of many protocols. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Tomasz Zielonka
On Tue, Aug 30, 2005 at 12:41:20PM +0200, Joel Reymont wrote: > Erlang does this nicely, I replied to the LtU thread. I positively > got the impression that nobody was parsing binary data in Haskell ;). I am doing this quite often, I apologize for not sharing my experience and promise to improve

Re: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Joel Reymont
Erlang does this nicely, I replied to the LtU thread. I positively got the impression that nobody was parsing binary data in Haskell ;). On Aug 30, 2005, at 12:29 PM, Bayley, Alistair wrote: There's a request on LtU for a similar ability (somewhat wider in scope, perhaps): http://lambda-th

RE: [Haskell-cafe] Haskell poker server

2005-08-30 Thread Bayley, Alistair
> From: Cale Gibbard [mailto:[EMAIL PROTECTED] > > Well, here's an attempt at a start on a similar mechanism for Haskell: > > -- (start Packet.hs) > module Packet where > > import Data.Bits > import Data.Word > > class Packet a where > readPacket :: [Word8] -> (a, [Word8]) ... Th

Re: [Haskell-cafe] Haskell poker server

2005-08-28 Thread Cale Gibbard
Well, here's an attempt at a start on a similar mechanism for Haskell: -- (start Packet.hs) module Packet where import Data.Bits import Data.Word concatBits :: (Integral a, Bits a, Bits b) => [a] -> b concatBits [] = 0 concatBits (x:xs) = shift (fromIntegral x) (sum (map bitSize xs)) + c

Re: [Haskell-cafe] Haskell poker server

2005-08-28 Thread Joel Reymont
Alistair, Thanks alot for your examples. I still have one unanswered question... How would you read a tuple of values (24, GID, Seq) like in my Erlang example, where 24 is one byte, GID is a 4-byte integer and Seq is a 2- byte word? Is there an elegant way of specifying packet format and re

Re: [Haskell-cafe] Haskell poker server

2005-08-28 Thread Alistair Bayley
> I wrote a poker server in Erlang (link in signature) and I'm learning > Haskell with an eye towards using it with Erlang. Erlang would take > care of the overall control, etc. whereas Haskell would take care of > the rest. I'm stuck with the basics I'm afraid and Haskell hackers > don't seem to b