Haskell 编译器在以下函数上抛出错误:
balancedMax :: Int -> Int -> Int
balancedMax -1 _ = -1
balancedMax _ -1 = -1
balancedMax a b = max a b
翻转标志可以解决问题:
balancedMax :: Int -> Int -> Int
balancedMax 1 _ = -1
balancedMax _ 1 = -1
balancedMax a b = max a b
为什么模式匹配在否定上失败,什么是干净的解决方法?