[Haskell-cafe] Re: ByteString comparison question (was: another
Newbie performance question)
Philip Müller
mail at philip.in-aachen.net
Sun May 18 13:56:19 EDT 2008
Achim Schneider schrieb:
> Philip Müller <mail at philip.in-aachen.net> wrote:
>
>> I do not know how to compare a Word8 to a Char. Or maybe I don't need
>> to?
>>
> You don't need to, just use ByteString.Char8 or ByteString.Lazy.Char8.
Could you give a short example of how to check whether a ByteString
starts with a comma (',')?
I tried this
import qualified Data.ByteString.Char8 as B
readCSVLine :: B.ByteString -- line as String
-> [B.ByteString] -- line broken down into the value Strings
readCSVLine = unfoldr builder
where
builder xs | xs == B.empty = Nothing
| otherwise = Just $ readField xs
readField xs | xs == B.empty = (B.empty,B.empty)
| B.head xs == ',' = (B.empty, B.tail xs)
| B.head xs == '"' = (field, B.tail rest)
where
(field,rest) = B.break (== '"') xs
But now I get strange errors when compiling, like
Main.o: In function `rTD_info':
(.text+0x5a): undefined reference to
`bytestringzm0zi9zi1zi0_DataziByteStringziInternal_zdf2_closure'
Is this a problem with my Code or is it just GHC unable to find the
ByteString package?
Regards
Philip
More information about the Haskell-Cafe
mailing list