[Haskell-beginners] Pattern match(es) are overlapped ... but I do not see that they do
Nathan Hüsken
nathan.huesken at posteo.de
Sun Sep 1 00:46:01 CEST 2013
Hey,
I have the following code (which uses wxHaskell):
import Graphics.UI.WX
import Graphics.UI.WX.Controls
import Graphics.UI.WXCore
import Graphics.UI.WXCore.Events
(...)
dealWithUnsavedChanges :: Var ProgramState -> TextCtrl a -> IO Bool
dealWithUnsavedChanges state tc = do
ProgramState unsavedChanges _ <- varGet state
if not unsavedChanges then return True else do
res <- messageDialog tc "Unsaved changes ..." "You have unsaved
changes, do you want to save them?" (wxYES_NO .+. wxCANCEL .+.
wxICON_EXCLAMATION)
case res of
wxID_CANCEL -> return False
wxID_NO -> return True
wxID_YES -> do
onSave state tc
-- check if saving worked
ProgramState newUnsavedChanges _ <- varGet state
return (not newUnsavedChanges)
When I compile it, I get:
Main.hs:130:5: Warning:
Pattern match(es) are overlapped
In a case alternative:
wxID_NO -> ...
wxID_YES -> ...
which is strange. I checked, wxID_NO is defined as 5104 and wxID_YES as
5103. So they are not overlapping. On the other hand, when I replace the
wxID_NO/YES/CANCEL with the actual values, the warning vanishes.
Any Idea what this could be?
Thanks!
Nathan
More information about the Beginners
mailing list