As @Rhymoid explained in a comment, this is just a coincidence with a template in which nothing is connected and can be replaced with a name (which will be connected). Perhaps it would be more clear to write this as follows:
case () of _ | someBool -> ... | somOtherBool -> ...
It can also be written (more or less equivalent) as
case () of () | someBool -> ... | someOtherBool -> ...
These are the guards. You may also have protection in a more complex case match:
case m of Just x | someBool -> ... | someOtherBool -> ... Nothing | someThirdBool -> ... | someFourthBool -> ...
with as many guards as you want in every match.
The reason for writing the code you pointed out is the trick to get a brief if-then-else style thing with several possibilities. Source code can be better written with the MultiWayIf extension MultiWayIf :
{-# LANGUAGE MultiWayIf #-} ... if | someBool -> ... | someOtherBool -> ...
MultiWayIf can also be used with any number of boolean "cases", like the source code.
Underscore can be used in any pattern match for any pattern where you don't need a value later. For instance:
andBool True True = True andBool _ _ = False
or
f (Just _) = 'J' f _ = 'N'
source share