converting things to and from binary

George Russell ger@tzi.de
Wed, 21 May 2003 17:56:41 +0200


Here's another reason why I think it's better to make the monad
used variable (as with my framework but not Malcolm's).  The main
method I use for encoding binary data needs access to a bit of extra
information about what it is encoding it for.  This basically
can't be done within Malcolm's framework except by, er, parking
the extra stuff in a global variable and then using another global
lock as otherwise hell will pop when two threads try to use this
mechanism at once.  It can be done within my framework, though you
need to change it slightly to make the monad in question one of the
class variables.  Thus you would have

    class HasBinary a monad

Most types (integers, lists and so on) would just instance this for
all values of monad.  Where you need extra state you would create
an extra monad for the purpose, and just instance for that monad.

This is sufficiently worthwhile to me that I think I shall probably
implement it, and then see whether anyone else is interested in using
it.  I don't think you need any extensions apart from FFI and
multi-parameter type-classes, AND some way of writing/reading
CChars and CStringLen's to Handles, how do I do this please Simon?
hPutChar/hGetChar/hPutBuf/hGetBuf?