[Haskell-cafe] Haskell poker server

John Meacham john at repetae.net
Tue Aug 30 20:59:53 EDT 2005

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- 
> byte word? Is there an elegant way of specifying packet format and  
> reading/writing Haskell data according to it?

If you don't actually need a binary format (or don't care about the
format) you can use the 'Show' and 'Read' classes to turn values into
strings and back again.

so, you would do a show on one side and send the string, and then on the
other side 'read' it and you will get the same value out. Instances
exist for all built in types where it makes sense, and you can
automatically derive instances for your own types. 


John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Haskell-Cafe mailing list