こんにちは、私はこれを自分で理解できず、オンラインで例を見つけることもできませんでした
たぶんまたはガードを使用しようとしていますが、見つかった例には2つの変数しかありません.2つ以上の例を編集またはフォローすると、エラーが発生します。
--maybe example
Fun :: Double -> Double -> Double -> Maybe Double
Fun a b c
| a >= -1.0 || a <= 1.0 || b >= -1.0 || b <=1.0 || c /=0 || c >= -1.0 = Nothing
| otherwise = Just max( ((c^ (-c)) + (a^(-c)-1.0) ^ (a+ (-1.0/a))) 0.0)
gchiのエラー
The function `Just' is applied to two arguments,
but its type `a0 -> Maybe a0' has only one
フリントが与えている間
No suggestions
代わりにガードを使用しようとすると、別のエラーが発生します
--guard example
Fun :: Double -> Double -> Double -> Maybe Double
Fun a b c
| a >= -1.0 || a <= 1.0 || b >= -1.0 || b <=1.0 || c /=0 || c >= -1.0 = error "Value out of range "
| otherwise = max( ((c^ (-c)) + (a^(-c)-1.0) ^ (a+ (-1.0/a))) 0.0)
そしてheres ghcとhlintsエラー
test.hs:10:1:
Invalid type signature: Fun :: Double
-> Double -> Double -> Maybe Double
Should be of form <variable> :: <type>
$ hlint test.hs
Error message:
Left-hand side of type signature is not a variable: Fun
Code:
Fun :: Double -> Double -> Double -> Maybe Double
> Fun a b c