次の 2 つの関数は、空の文字列を指定すると動作が異なります。
guardMatch l@(x:xs)
| x == '-' = "negative " ++ xs
| otherwise = l
patternMatch ('-':xs) = "negative " ++ xs
patternMatch l = l
ここに私の出力:
*Main> guardMatch ""
"*** Exception: matching.hs:(1,1)-(3,20): Non-exhaustive patterns in function guardMatch
*Main> patternMatch ""
""
質問: 'otherwise' クローズが空の文字列をキャッチしないのはなぜですか?