2
No instance for (Fractional Int) arising from a use of `leap'
Possible fix: add an instance declaration for (Fractional Int)
In the first argument of `(==)', namely `leap (x)'
In the second argument of `(&&)', namely `leap (x) == 1'
In the expression: (y == 2) && leap (x) == 1
獲得在ghci中加載文件時,這個錯誤分數詮釋錯誤[哈斯克爾]
這是造成
daysInMonth :: Int -> Int -> Int
daysInMonth y x
| (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) = 31
| (y == 4 || y == 6 || y == 9 || y == 11) = 30
| (y == 2) && leap(x) == 1 = 28
| (y == 2) && leap(x) == 0 = 29
where
leap a = if (a/4) == 0 then return 1 else return 0
好的謝謝你的建議:)葉,我知道我們的講師說,使用製作更簡單的目的。 – rob1994