[Haskell-cafe] How does one use Text.Regex.Base.RegexLike?

Lyle Kopnicky lists at qseep.net
Tue Dec 23 15:09:48 EST 2008


Yes, sort of. It enables me to get some simple examples working with (=~).
But I still don't know how to get makeRegex to work. You need it to specify
options like case insensitivity, or to use functions like matchAllText.

On Tue, Dec 23, 2008 at 11:29 AM, Jeremy Shaw <jeremy at n-heptane.com> wrote:

> Hello,
>
> Does this help?
>
>
> http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/
>
> j.
>
> At Tue, 23 Dec 2008 11:21:41 -0800,
> Lyle Kopnicky wrote:
> >
> > [1  <multipart/alternative (7bit)>]
> > [1.1  <text/plain; ISO-8859-1 (7bit)>]
> > I'm trying to migrate code from using the old Text.Regex to the new
> > Text.Regex.Base. But, I'm getting type errors. I can't even create a
> regex.
> > Looking at the docs, it seems like this should print "bcd":
> >
> > import Data.Array
> > import Text.Regex.Base
> > import Text.Regex.Posix
> >
> > rx = makeRegex "a(.*)A"
> >
> > Just (_, mt, _) = matchOnceText rx "abcdA"
> >
> > main = putStrLn (fst (mt ! 0))
> >
> >
> > But I get an error:
> >
> > src\regex.hs:5:5:
> >     No instance for (RegexMaker regex compOpt execOpt [Char])
> >       arising from a use of `makeRegex' at src\regex.hs:5:5-22
> >     Possible fix:
> >       add an instance declaration for
> >       (RegexMaker regex compOpt execOpt [Char])
> >     In the expression: makeRegex "a(.*)A"
> >     In the definition of `rx': rx = makeRegex "a(.*)A"
> >
> > src\regex.hs:7:18:
> >     No instance for (RegexLike regex [Char])
> >       arising from a use of `matchOnceText' at src\regex.hs:7:18-41
> >     Possible fix:
> >       add an instance declaration for (RegexLike regex [Char])
> >     In the expression: matchOnceText rx "abcdA"
> >     In a pattern binding: Just (_, mt, _) = matchOnceText rx "abcdA"
> >
> > Why does it say there is no instance? Isn't the instance imported by
> > Text.Regex.Posix?
> >
> > Why in the world is it so complicated just to get a matched substring out
> of
> > the text? Is there an easier way?
> >
> > Thanks,
> > Lyle
> > [1.2  <text/html; ISO-8859-1 (7bit)>]
> >
> > [2  <text/plain; us-ascii (7bit)>]
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/a6d1ebbb/attachment.htm


More information about the Haskell-Cafe mailing list