when debug (putStrLn "Debugging")will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.
>>> whenM (pure False) $ putTextLn "No text :(" >>> whenM (pure True) $ putTextLn "Yes text :)" Yes text :) >>> whenM (Just True) (pure ()) Just () >>> whenM (Just False) (pure ()) Just () >>> whenM Nothing (pure ()) Nothing
>>> whenNotNull [] $ \(b :| _) -> print (not b) >>> whenNotNull [False,True] $ \(b :| _) -> print (not b) True
>>> whenJust Nothing $ \b -> print (not b) >>> whenJust (Just True) $ \b -> print (not b) False
>>> whenNothing Nothing [True, False] [True,False] >>> whenNothing (Just True) [True, False] [True]
>>> whenNothing_ Nothing $ putTextLn "Nothing!" Nothing! >>> whenNothing_ (Just True) $ putTextLn "Nothing!"