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