[Haskell-beginners] Non-exhaustive case leads to runtime error?
rafalk at cse.unsw.edu.au
Tue Sep 9 16:19:09 EDT 2008
I just ran into the following situation in an IO do block:
case msel of Just sel -> do toggleFretArea selectionRef sel
Nothing -> return ()
except I omitted the last line. I expected the compiler to complain, but
it silently compiled it, and I got a runtime exception when the program
Is this behaviour intentional? Can I get ghc to warn me about it anyway
(something like -Wall)?
Two more guiding questions:
1. What is a good idiom for "In this case do blah otherwise don't do
2. Is there a shorter way of writing a no-op in a do block than "return ()"?
Thanks in advance!
More information about the Beginners