[Haskell-cafe] Battling laziness
Joel Reymont
joelr1 at gmail.com
Fri Dec 16 11:25:54 EST 2005
Most of the samples in randomplay.hp look like this:
BEGIN_SAMPLE 1.76
(170)Script.Array.CAF 8
(154)Script.CmdType.CAF 64
(165)Script.PickleCmd.CAF 760
(197)Script.PokerClient.CAF 8
(156)Script.Command.CAF 24
(282)Main.CAF 285752
(163)Script.Pickle.CAF 16
(311)/launchScripts#8/laun... 93464
END_SAMPLE 1.76
I'm pickling to/from unboxed arrays of Word8
type MutByteArray = IOUArray Int Word8
type ByteArray = UArray Int Word8
type Index = Int
CmdType is (Word8, Word8) that tells me what pickler to use.
PickleCmd looks like this:
puCommand :: (Word8, Word8) -> PU Command
puCommand (116, 2) =
sequ tableID endian32
(\a -> sequ password wstring
(\b -> sequ localIP wstring
(\c -> sequ affiliateID (list endian32 byte)
(\d -> lift $
ClConnectGame a b c d
))))
puCommand (36, 1) =
...
Command has about 250 constructors for the different records that can
be send/received. These records can be somewhat nested and have lists
of other records inside them. Like SrvServerInfo. Could this be where
the polymorphism is coming from, i.e. the "*" are my Commands that
are being unpickled? Fields in command all have strictness
annotations, btw.
Thanks, Joel
--
http://wagerlabs.com/
More information about the Haskell-Cafe
mailing list