[Haskell-i18n] SourceForge Project Active

Glynn Clements glynn.clements@virgin.net
Tue, 3 Sep 2002 07:49:02 +0100


Sven Moritz Hallberg wrote:

> decodeOne :: [Word8] -> (Either Error Char, Int, [Word8])
>    -- 2nd. component: number of bytes consumed,
>    -- 3rd. component: rest of bytes
> decode    :: [Word8] -> (String, [(Error,Int)])
>    -- 2nd. component: list of errors and their index in the byte stream
>    --                 Maybe we should reverse the order of error/index
>    --                 so it looks like any association list?
> 
> Comments welcome.

IMHO:

1. Decoders should present a consistent interface; possibly by means
of a class. Modal encodings would need some kind of state.

2. "decode" should return the remaining bytes, in case the input ends
with a partial character (or contains errors; see next).

3. The basic decoder interface shouldn't attempt to recover from
errors. Rather, it should return the list of complete characters, the
list of remaining octets, and the final state. Any error recovery
should be an optional add-on.

-- 
Glynn Clements <glynn.clements@virgin.net>