[Haskell-cafe] About Regex question
zaxis
z_axis at 163.com
Thu Nov 5 06:39:50 EST 2009
import Text.Regex.Posix
import Data.Char
import Data.List
guessKeys line = concat $ intersperse "-" (modifiers ++ [map toLower key])
where modifiers = map (!!1) (line =~ "(mod|shift|control)Mask")
(_, _, _, [key]) = line =~ "xK_(\\w+)" :: (String, String, String,
[String])
aaa line = map (!!1) (line =~ "(mod|shift|control)Mask")
bbb line = line =~ "xK_(\\w+)" :: (String, String, String, [String])
In ghci
>guessKeys "modF1"
"*** Exception: Test.hs:8:10-85: Irrefutable pattern failed for pattern (_,
_, _
, [key])
> aaa "modF1"
<interactive>:1:0:
No instance for (Text.Regex.Base.RegexLike.RegexContext
Regex [Char] [[a]])
arising from a use of `aaa' at <interactive>:1:0-10
> bbb "modF1"
("modF1","","",[])
I just extract the functions from where clause of guessKeys. But why are
there different running result ?
Sincerely!
-----
fac n = foldr (*) 1 [1..n]
--
View this message in context: http://old.nabble.com/About-Regex-question-tp26211696p26211696.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list