Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Haskell Serialization (Ashish Agarwal)
2. Re: Haskell Serialization (Daniel Fischer)
3. Re: Haskell Serialization
(Stephen Blackheath [to Haskell-Beginners])
----------------------------------------------------------------------
Message: 1
Date: Wed, 12 May 2010 13:15:42 -0400
From: Ashish Agarwal <[email protected]>
Subject: Re: [Haskell-beginners] Haskell Serialization
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
>> get (0::Word8)
>> getWord8be 0
>
> Make that
>
> put (0 :: Word16)
> putWord16be 0
>
> ?
Yes, thanks for the correction. Word8 was a bad choice since endianness is
not an issue.
Thanks for all the advice. It seems I should avoid making my types instances
of Binary. In fact, this relates to another design issue I've been grappling
with, supporting multiple versions of the protocol. Probably I'll need
something like, putProtVersion1, putProtVersion2, etc. Or something along
this line.
On Tue, May 11, 2010 at 3:41 PM, Daniel Fischer <[email protected]>wrote:
> On Tuesday 11 May 2010 21:01:19, Stephen Tetley wrote:
> > On 11 May 2010 19:16, Daniel Fischer <[email protected]> wrote:
> > > Int8 and Word8 are unproblematic (unless you have a ones-complement
> > > machine), the problems appear only for larger types, [SNIP]
> >
> > Hi Daniel
> >
> > Likely I was revealing a personal bias on that one, the only protocol
> > I've implemented where Int8 has featured has been MIDI.
> >
> > If MIDI isn't ones-complement, my codes - I've written decoders /
> > encoders several times - have been wrong for years...
>
> I've no idea how MIDI messages/files/streams are interpreted, I was
> thinking about the hardware, how the ALU interprets the bit-pattern for
> arithmetic.
>
> >
> > Best wishes
> >
> > Stephen
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100512/7cefbd99/attachment-0001.html
------------------------------
Message: 2
Date: Wed, 12 May 2010 19:35:11 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Haskell Serialization
To: Ashish Agarwal <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Wednesday 12 May 2010 19:15:42, Ashish Agarwal wrote:
> >> get (0::Word8)
> >> getWord8be 0
> >
> > Make that
> >
> > put (0 :: Word16)
> > putWord16be 0
> >
> > ?
>
> Yes, thanks for the correction. Word8 was a bad choice since endianness
> is not an issue.
>
> Thanks for all the advice. It seems I should avoid making my types
> instances of Binary.
I wouldn't go so far, just stop and think before you do.
> In fact, this relates to another design issue I've
> been grappling with, supporting multiple versions of the protocol.
> Probably I'll need something like, putProtVersion1, putProtVersion2,
> etc. Or something along this line.
>
That, or
data Protocol a
= Prot
{ putVal :: a -> Put
, getVal :: Get a
}
ieee754 :: Protocol Double
ieee754 = Prot { putVal=... , getVal=... }
json :: Protocol JSON
json = ...
work args = do
stuff
mapM_ (putVal prot) vals
moreStuff
------------------------------
Message: 3
Date: Thu, 13 May 2010 08:35:57 +1200
From: "Stephen Blackheath [to Haskell-Beginners]"
<[email protected]>
Subject: Re: [Haskell-beginners] Haskell Serialization
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Ashish,
I've been using XML picklers for serialization, which you might want to
consider if you can handle a little extra CPU/data cost. I'm the author
of hexpat-pickle, so this is a plug for my package. I lifted the idea
wholesale from the HXT package.
Handling changes in protocol version is really easy. I've been doing a
lot of
xpSomething = new `xpTryCatch` old
where
new = ...
old = ...
If the new encoding fails to parse, it tries the old one, and on
transmission it uses the new one. I find it very quick and convenient
to bang out a new pickler now that I'm familiar with it. You write your
pickler and your unpickler with the same code - it works well.
I am also working on hexpat-iteratee which is a lot more socket friendly
since it doesn't use Haskell's lazy I/O. The learning curve increases a
little bit with doing it that way, though.
Steve
On 13/05/10 05:15, Ashish Agarwal wrote:
> Thanks for all the advice. It seems I should avoid making my types
> instances of Binary. In fact, this relates to another design issue I've
> been grappling with, supporting multiple versions of the protocol.
> Probably I'll need something like, putProtVersion1, putProtVersion2,
> etc. Or something along this line.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 23, Issue 16
*****************************************