
This works fine keyboardAct a d p (SpecialKey KeyLeft) Down Modifiers {shift=Down, ctrl=Up, alt=Up} = do (x,y) <- get p p $= (x-0.1, y) This keyboardAct a d p (SpecialKey KeyLeft) Down shiftDown = do (x,y) <- get p p $= (x-0.1, y) where, shiftDown = Modifiers {shift=Down, ctrl=Up, alt=Up} gives me : KeyBindings.hs:32:1: Warning: Pattern match(es) are overlapped In an equation for `keyboardAct': keyboardAct angle delta p (SpecialKey KeyLeft) Down Modifiers {shift = Up, ctrl = Up, alt = Up} = ... keyboardAct is used several times via pattern matching, e.g. keyboardAct angle delta p (SpecialKey KeyLeft) Down Modifiers {shift=Up, ctrl=Up, alt=Up} = do (x,y) <- get p a <- get angle d <- get delta angle $= a+d and there are several more. So clearly, the pattern match is overlapped, just like the warning says. The question is why I don't get the same warning before I make use of shiftDown. Thanks Brian

On Thu, Oct 23, 2014 at 2:23 PM,
keyboardAct a d p (SpecialKey KeyLeft) Down shiftDown = do (x,y) <- get p p $= (x-0.1, y)
where,
shiftDown = Modifiers {shift=Down, ctrl=Up, alt=Up}
You can't use a definition like that directly in a pattern match; a name starting with lowercase is a new binding, not the value of some existing binding. You can instead use a guard or, sometimes, a pattern guard. That is, keyboardAct a d p (SpecialKey KeyLeft) Down shiftDown = is identical to keyboardAct a d p (SpecialKey KeyLeft) Down x = aside from the name of the new local binding it introduces. It does *not* use an existing binding for shiftDown or x, it always creates a new one. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (2)
-
Brandon Allbery
-
briand@aracnet.com