[Haskell-cafe] Haskell poker server

Joel Reymont joelr1 at gmail.com
Sun Aug 28 14:59:49 EDT 2005


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 be active this weekend ;).

I'm trying to write the poker server in Haskell to compare against my  
other implementations, specifically the Erlang one. The server talks  
a binary protocol. A packet notifying the player that a game has  
started looks like this:

0    1     5     7
| 24 | GID | Seq |

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, GID, Seq}.

My code shoots tuples like {24, GID, Seq} back and forth and all is  
fine. How would I do this in Haskell, though? Some folks have kindly  
supplied me with references to the various binary I/O packages and  
some server examples.

I'm wondering, though, if someone would be kind enough to show how a  
packet like above could be sent and retrieved using Haskell sockets.  
I think this would serve as an excellent example to be posted at the  
Haskell Wiki. I also think that Haskell has a lot of interesting  
features that could well simplify my poker coding. I just need a  
little help to get started.

     Thanks, Joel


More information about the Haskell-Cafe mailing list