jethr0/Sokoban — pull request #1 by errge (2012-06-29 12:48:54+00:00)
Title: implementation of your pattern match idea

Hi,

I've seen your uncut video, thanks, I enjoyed it a lot! It got me thinking about your pattern match idea inside tryEvent and how the generalization didn't work out. After some thinking, I came up with the attached patch.

The trick is, that you can't use guard, because that's not a pattern match failure and as the gtkhs documentation says, inside tryEvent you have to produce a pattern match failure to unqualify the branch. An easy way to do this is to True <- return condition.

Also, I sent a mail to the gtkhs developers about this issue and that they should consider supporting mzero (used by guard) too.

Here is the relevant code, if you want to take a look: http://hackage.haskell.org/packages/archive/gtk/0.12.3.1/doc/html/src/Graphics-UI-Gtk-Gdk-EventM.html#tryEvent

Thanks again for the video,
Gergely