
Hi. I'm trying to use pcre-light in a small text-manip app. However, the module seems to want the incoming text data as a ByteString, whereas I in my child-like naivety am taking the data from stdin as Strings. After searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is: code: -------- Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' -------- So I'm not sure what to do. -- frigidcode.com

On Tue, Jan 01, 2013 at 01:53:44AM -0900, Christopher Howard wrote:
Hi. I'm trying to use pcre-light in a small text-manip app. However, the module seems to want the incoming text data as a ByteString, whereas I in my child-like naivety am taking the data from stdin as Strings. After searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is:
code: -------- Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' --------
So I'm not sure what to do.
Is it a mismatch between strict and lazy bytestrings? iustin

See the answer to http://stackoverflow.com/questions/12576817/couldnt-match-expected-type-with... In the future, provide a small code snippet as well so that anyone helping can easily point out where you're messing up. On 01/01/13 12:03, Iustin Pop wrote:
On Tue, Jan 01, 2013 at 01:53:44AM -0900, Christopher Howard wrote:
Hi. I'm trying to use pcre-light in a small text-manip app. However, the module seems to want the incoming text data as a ByteString, whereas I in my child-like naivety am taking the data from stdin as Strings. After searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is:
code: -------- Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' --------
So I'm not sure what to do. Is it a mismatch between strict and lazy bytestrings?
iustin
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 01/01/2013 04:31 AM, Mateusz Kowalczyk wrote:
See the answer to http://stackoverflow.com/questions/12576817/couldnt-match-expected-type-with...
In the future, provide a small code snippet as well so that anyone helping can easily point out where you're messing up.
On 01/01/13 12:03, Iustin Pop wrote:
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
With some more research, I figured it out: The problem was, it seems, that 8 bit ByteStrings are not the same as UTF8 ByteStrings. So I used the pack function from Data.ByteString.Char8, and this compiles fine. -- frigidcode.com

On Dienstag, 1. Januar 2013, 11:41:45, Christopher Howard wrote:
With some more research, I figured it out: The problem was, it seems, that 8 bit ByteStrings are not the same as UTF8 ByteStrings. So I used the pack function from Data.ByteString.Char8, and this compiles fine.
It's not that. The UTF8 ByteStrings are the ordinary ByteStrings, the utf8- string package just provides a few utility functions encoding, decoding etc.
searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is:
code: -------- Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' --------
That means that your utf8-string package was built against version 0.9.2.1 of the bytestring package, but you have a newer version installed, and that package is what is used in the current module. So fromString creates a bytestring-0.9.2.1:Data.ByteString.Internal.ByteString - which is the exact package version and location of the definition of the type - while the consumer expected ByteString from bytestring-0.10.0.0 (or so). Whenever an error message specifies a package version in a type error (be it "Couldn't match expected..." or a "No instance..." class error), the problem is that more than one package version is involved. You need to - specify the exact version of the package to use with a `-package` flag, - use Cabal to specify the exact versions of the packages, or - rebuild the offending package(s) against newer versions of the dependencies to make them compatible with the automatically chosen versions. Unless your Strings only contain ASCII symbols, using Data.ByteString.Char8.pack is probably wrong, since that just truncates Chars to the least significant 8 bits. Reinstall your utf8-string so that it is built using the current bytestring version you have, $ ghc-pkg unregister utf8-string $ cabal install utf8-string If you have other packages depending on utf8-string, ghc-pkg should warn about breaking them and not unregister utf8-string at first. If those aren't too many, reinstalling them too would be the best option.
participants (4)
-
Christopher Howard
-
Daniel Fischer
-
Iustin Pop
-
Mateusz Kowalczyk