
Am Dienstag, 23. Dezember 2008 21:09 schrieb Lyle Kopnicky:
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.
Your problem is that GHC can't know which instance to choose. You can help it by giving a type signature, e.g. rx :: Regex rx = makeRegex "a(.*)A" HTH, Daniel
At Tue, 23 Dec 2008 11:21:41 -0800,
Lyle Kopnicky wrote:
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
] [2
] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe