[Haskell-cafe] Re: [Haskell] BitSyntax for Haskell

2006-09-28 Thread Einar Karttunen
On 26.09 10:01, Adam Langley wrote:
> >For the decoding part:
> >* Provide a monadic interface
> 
> Are you suggesting a monad to pass in the input around, or that it
> returns mzero on error? The latter makes more sense to me.

Yes. Also make it possible for user supplied functions to fail
in better ways than to produce Either or use error.

> >* Add a test part to ReadType:
> >Test :: ReadType a -> (a -> Bool) -> ReadType Test
> >(or a -> m ()) in the monadic case.
> 
> Again, I'm not clear what you are thinking of here?

In some protocols I am using there are some fixed bytes
which I want to ignore (no Haskell value produced), but
check that they are valid in the data stream.

- Einar Karttunen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] BitSyntax for Haskell

2006-09-25 Thread Einar Karttunen
On 23.09 15:00, Adam Langley wrote:
> Erlang's bit syntax[1] is a great for building and breaking up binary
> structures. I've knocked up something similar (although a little
> clumsy) for Haskell:
> 
> http://www.imperialviolet.org/binary/bitsyntax/
> http://www.imperialviolet.org/binary/bitsyntax/BitSyntax.hs
> 
> I'm sure that this isn't the best possible way to do this, but it
> suffices at this stage for many problems.

This looks very nice.

Here are some feature wishes:

BitBlock: add a way to encode length prefixed ByteStrings.

For the decoding part:
* Provide a monadic interface
* Add a test part to ReadType: 
Test :: ReadType a -> (a -> Bool) -> ReadType Test
(or a -> m ()) in the monadic case.
* Add a way to limit the size of a LengthPrefixed:
e.g. [Unsigned 4, LengthPrefixed] is very unsafe, the app should
have a way to control the maximum length.

- Einar Karttunen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe