[Haskell-cafe] ByteString comparison question

Ketil Malde ketil at malde.org
Sun May 18 13:53:25 EDT 2008


Philip Müller <mail at philip.in-aachen.net> writes:

> import qualified Data.ByteString as B
> import qualified Data.ByteString.Char8 as C8

Note that these use the same underlying data structure, but Char8
interprets the contents as Char instead of Word8.  So the B.heads and
B.break should be CS8 - for consistency's sake, you could replace them
all and drop the "B" import.

>                   readField xs | xs == B.empty    = ([],[])
>                                | B.head xs == ',' = ([], B.tail xs)
>                                | B.head xs == '"' = (field, B.tail rest)
>                                     where
>                                        field,rest) = B.break (== '"') xs

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list