[Haskell-cafe] ANNOUNCE: binary: high performance, pure binary serialisation

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Jan 30 05:25:31 EST 2007

On Tue, Jan 30, 2007 at 09:38:26AM +0000, Ross Paterson wrote:
> On Tue, Jan 30, 2007 at 09:52:01AM +1100, Donald Bruce Stewart wrote:
> > ross:
> > > why do you need a Put monad, which always seems to have
> > > the argument type ()?  Monoids really are underappreciated.
> > 
> > For the syntax, and So that people can directly port their code from
> > NewBinary.  (The instances are basically unchanged).
> And so the successor to binary must have the same interface, and so on
> forever.  The backward compatibility argument seems weak to me, leaving
> only the advantage of do-notation.

How about having both interfaces, so you can use the one you like

    class Binary t where
        -- | Encode a value in the Put monad.
        put :: t -> Put
        put x = Put ((), build x)
        -- | Encode a value using the Builder monoid
        build :: t -> Builder
        build x = snd (unPut (put x))
        -- | Decode a value in the Get monad
        get :: Get t

The downside is that GHC probably wouldn't warn about undefined methods,
or would it?

Best regards

More information about the Haskell-Cafe mailing list