[Haskell-cafe] Re: Declarative binary protocols
Martijn van Steenbergen
martijn at van.steenbergen.nl
Tue Jan 19 05:50:55 EST 2010
Antoine Latter wrote:
> getResponse = do
> require 256
> x <- getX
> len <- getWord16be
> y <- getY
> z <- getZ
> require (fromIntegral len * 8)
> a <- getA
> b <- getB
> return $ Response x y z a b c
This looks like code that could be written in applicative style, in
which case you could analyze the parser and automatically compute how
many bytes are needed, removing the need for explicit calls to require.
Groetjes,
Martijn.
More information about the Haskell-Cafe
mailing list