我有简单的代码
delta a b c = b*b - (4*a*c)
mz1 :: Double -> Double -> Double -> Double
mz1 a b c = (-b - sqrt(delta a b c)) / (2*a)
mz2 :: Double -> Double -> Double -> Double
mz2 a b c = (-b + sqrt(delta a b c)) / (2*a)
mz0 :: Double -> Double -> Double -> Double
mz0 a b c = (-b) / (2*a)
kwad :: (Enum a) => a -> a -> a -> Either Double Bool
kwad a b c
| delta a b c == 0 = Left mz0 a b c
| delta a b c < 0 = Right False
| otherwise = Left mz1 a b c
我刚开始学习 Haskell,我不知道如何返回 Bool 或 Double,有人可以帮忙吗?
错误是:
Couldn't match expected type `a -> a -> a -> Either Double Bool' with actual type `Either (Double -> Double -> Double -> Double) >b0' The function `Left' is applied to four arguments, but its type `(Double -> Double -> Double -> Double) -> Either (Double -> Double -> Double -> Double) b0' has only one