
Hi, I am battling with Data.ByteString.Lazy.Char8, and currently losing. Any help gratefully received. Here's my code: import qualified Data.ByteString.Lazy.Char8 as B import Text.Regex.Posix ((=~)) test = B.pack "abc" =~ B.pack "b" :: Bool This works fine without the ".Lazy", and is also fine under GHC 6.8.1, but with GHC 6.10.1, it fails with: No instances for (Text.Regex.Base.RegexLike.RegexLike Text.Regex.Posix.Wrap.Regex B.ByteString, Text.Regex.Base.RegexLike.RegexMaker Text.Regex.Posix.Wrap.Regex Text.Regex.Posix.Wrap.CompOption Text.Regex.Posix.Wrap.ExecOption B.ByteString) I then thought I might work around the problem by converting lazy ByteStrings to strict ones in order to do the regex match. I discovered toChunks, which is advertised in the documentation as type ByteString -> [ByteString], but it actually appears to be of type toChunks :: ByteString -> [Data.ByteString.Internal.ByteString] and I can't see any way of converting a Data.ByteString.Internal.ByteString to a (strict) ByteString. Does anyone know whether this is (a) bug(s) in GHC, Data.ByteString, Text.Regex.Posix or (maybe most likely) my own limited understanding? And any ideas for fixes or workarounds (other than the obvious one of downgrading to GHC 6.8)? Thanks in advance David

David Carter
I then thought I might work around the problem by converting lazy ByteStrings to strict ones in order to do the regex match.
strictBS :: LB.ByteString -> B.ByteString strictBS = B.concat . LB.toChunks lazyBS :: B.ByteString -> LB.ByteString lazyBS = LB.fromChunks . pure -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

http://pastebin.com/m88c7dc
It works fine if you delete the ".Lazy".
Enjoy, and thanks...
David
On Thu, Apr 16, 2009 at 12:35 AM, Jason Dusek
Could you pastebin something that demoes the error?
-- Jason Dusek

On Thu, 2009-04-16 at 12:49 +0100, David Carter wrote:
It works fine if you delete the ".Lazy".
Enjoy, and thanks...
This will be because the version of the regex lib you're using does not have an instance for lazy ByteStrings. Do you know what versions of the regex libs you were using in each case? They're not necessarily related to your ghc version if you installed the regex libs via cabal-install. Duncan
participants (4)
-
Achim Schneider
-
David Carter
-
Duncan Coutts
-
Jason Dusek