[Haskell-cafe] How does one use Text.Regex.Base.RegexLike?
Lyle Kopnicky
lists at qseep.net
Tue Dec 23 14:21:41 EST 2008
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/fd442bfe/attachment.htm
More information about the Haskell-Cafe
mailing list