[Haskell-beginners] Regex woes...

Daniel Fischer daniel.is.fischer at googlemail.com
Sat Jun 11 00:34:00 CEST 2011


On Saturday 11 June 2011, 00:15:43, Sean Charles wrote:
> I did a cabal update then:
> cabal install regex-base
> cabal install regex-compat
> cabal install regex-posix
> 
> Everything built and installed, there were no errors as far as I could
> tell. However, on attempting to get into regex on page 199 of my Real
> World Haskell book I get this error when trying to use [String] as the
> return type and I don't know why...
> 
> 
> GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer-gmp ... linking ... done.
> Loading package base ... linking ... done.
> Loading package ffi-1.0 ... linking ... done.
> Prelude> :m Text.Regex.Posix
> Prelude Text.Regex.Posix>
> 
> Prelude Text.Regex.Posix> "this is the string" =~ "th" :: [String]
> 
> <interactive>:1:0:
>      No instance for (RegexContext Regex [Char] [String])
>        arising from a use of `=~' at <interactive>:1:0-27
>      Possible fix:
>        add an instance declaration for
>        (RegexContext Regex [Char] [String])
>      In the expression: "this is the string" =~ "th" :: [String]
>      In the definition of `it':
>          it = "this is the string" =~ "th" :: [String]
> Prelude Text.Regex.Posix>
> 
> 
> I am trying to write a page scraper, I've already sucked pages with
> Network.HTTP and I thought it'd be easy to get the anchor tags!

I'm not familiar with the regex libraries, but that's come up occasionally.
No idea whether it's an error in RWH or a change in the libs.

IIRC, it works with a result type of [[String]] (and several others, cf. 
http://hackage.haskell.org/packages/archive/regex-
base/0.93.2/doc/html/Text-Regex-Base-RegexLike.html#t:RegexContext )



More information about the Beginners mailing list