Use regexps for className matching?

For example className =? "Google Mail" --> doShift "1" className =? "Google Calendar" --> doShift "1" would become className <some regexp matching operator> "Google .*" doShift "1" How to do this in Haskell? I couldn't find any examples of this in the config archive.. Henri

Henri Ducrocq
import Text.Regex.Posix ((=~))
q ~? x = fmap (=~ x) q
and then your example is simply
className ~? "Google .*" --> doShift "1"

mail:
Henri Ducrocq
writes: | For example | className =? "Google Mail" --> doShift "1" | className =? "Google Calendar" --> doShift "1" | would become | className <some regexp matching operator> "Google .*" doShift "1" | | How to do this in Haskell? I couldn't find any examples of this in the config | archive.. You can use one of the haskell regex libraries and define an operator for the managehook like so:
import Text.Regex.Posix ((=~))
q ~? x = fmap (=~ x) q
and then your example is simply
className ~? "Google .*" --> doShift "1"
Having someone interested write an extension module of regex combinators for this kind of thing would be useful. -- Don

Don Stewart
You can use one of the haskell regex libraries and define an operator for the managehook like so:
import Text.Regex.Posix ((=~))
q ~? x = fmap (=~ x) q
and then your example is simply
className ~? "Google .*" --> doShift "1"
Having someone interested write an extension module of regex combinators for this kind of thing would be useful.
-- Don
Other than lifting (=~) and possibly another function or two, what would this do? I'd be happy to put the two lines it takes to define (~?) into a module, but that seems a bit slim (I guess it couldn't hurt though). -- Gravity brings me down.

mail@justinbogner.com wrote:
Don Stewart
writes: Having someone interested write an extension module of regex combinators for this kind of thing would be useful.
-- Don
Other than lifting (=~) and possibly another function or two, what would this do? I'd be happy to put the two lines it takes to define (~?) into a module, but that seems a bit slim (I guess it couldn't hurt though).
Perhaps already existing auxiliary modules like ManageHelpers might be a good place.

I second that opinion!
On Mon, Feb 9, 2009 at 4:19 PM, Daniel Schoepe
mail@justinbogner.com wrote:
Don Stewart
writes: Having someone interested write an extension module of regex combinators for this kind of thing would be useful.
-- Don
Other than lifting (=~) and possibly another function or two, what would this do? I'd be happy to put the two lines it takes to define (~?) into a module, but that seems a bit slim (I guess it couldn't hurt though).
Perhaps already existing auxiliary modules like ManageHelpers might be a good place. _______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

Excerpts from Henri Ducrocq's message of Mon Feb 09 06:41:41 -0700 2009:
For example className =? "Google Mail" --> doShift "1" className =? "Google Calendar" --> doShift "1"
can become: import Data.List -- skipped fmap ("Google" `isPrefixOf`) className --> doShift "1" Also from Data.List are isSuffixOf and isInfixOf if you need those.
"bc" `isInfixOf` "abcdef" True
"bc" `isInfixOf` "bcdef" && "bc" `isInfixOf` "abc" True -- wmw

Thanks guys, that's even more solutions than I need.
On Mon, Feb 9, 2009 at 4:38 PM, Wirt Wolff
Excerpts from Henri Ducrocq's message of Mon Feb 09 06:41:41 -0700 2009:
For example className =? "Google Mail" --> doShift "1" className =? "Google Calendar" --> doShift "1"
can become:
import Data.List
-- skipped fmap ("Google" `isPrefixOf`) className --> doShift "1"
Also from Data.List are isSuffixOf and isInfixOf if you need those.
"bc" `isInfixOf` "abcdef" True
"bc" `isInfixOf` "bcdef" && "bc" `isInfixOf` "abc" True -- wmw
xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad
participants (6)
-
Daniel Schoepe
-
Don Stewart
-
Henri Ducrocq
-
Ismael Carnales
-
mail@justinbogner.com
-
Wirt Wolff