[Haskell-cafe] instance Binary Data

Johan Jeuring johanj at cs.uu.nl
Wed Jul 12 14:03:58 EDT 2006

Hello Bulat,

In the preliminary version of our paper about comparing
different approaches to generic programming in Haskell,
you can find a number of implementations of serialization
of values of arbitrary datatypes to lists of bits. Implementations
in Generic Haskell, DrIFT, SYB, and other approaches to
generic programming. I'm not sure if this is what you
are looking for, but it is at least related. See the paper
Comparing approaches to generic programming in Haskell
available via


Kind regards,

Johan Jeuring

On 12-jul-2006, at 8:15, Bulat Ziganshin wrote:

> Hello Joel,
> Tuesday, July 11, 2006, 1:44:31 PM, you wrote:
> thank you. i don't even thought how that can be done. i guess that
> Data values contains two parts - describing type (Constr?) and
> value itself. Serializing value is even easier than
> (already implemented) gshow/gread, and if it can use Binary instance
> instead of general algorithm whenever possible, it would be ideal
> Constr (or some type representation) is just value of some type, after
> all. So, for it's serialization we can use either gshow/gread, or
> general binary serialization algorithm, or make custom Binary instance
> that is the general thoughts, i hope that someone knowing better this
> infrastructure will explain this dark area to me
>> I don't see how this can work for arbitrary types without auto-
>> generating the serialization code. Once the code is generated you can
>> just store the type dictionary at the beginning of the file and use
>> it to deserialize.
>> I'm not sure this can be done on top of Binary since the type tag
>> will determine the Binary instance to use.
>> On Jul 11, 2006, at 7:38 AM, Bulat Ziganshin wrote:
>>> Hello Haskell,
>>> one Streams library user asked me about support of serialization
>>> TOGETHER with type information which means implementation of
>>> "instance Binary Data" (any other variants?). can anyone describe me
>>> how i can implement this? Binary instance is very like Show/Read,  
>>> just
>>> uses compact binary encoding of values
>> --
>> http://wagerlabs.com/
> -- 
> Best regards,
>  Bulat                            mailto:Bulat.Ziganshin at gmail.com
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list