[Haskell-cafe] pattern matches are overlapped

briand at aracnet.com briand at aracnet.com
Thu Oct 23 18:23:43 UTC 2014


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


More information about the Haskell-Cafe mailing list