检查返回是否为int - Haskell

Spr*_*out 0 int haskell

所以我想要做的是找出答案是否为整数并返回答案.这是一个例子.如果我输入5,它将返回1.

该示例检查整数是否可以被5或6整除,如果是,则返回它.

division :: Int -> Int
division 5
    | 5 / 5 == Int || 5 / 6 == Int = Int
    | otherwise                    = 2
Run Code Online (Sandbox Code Playgroud)

jam*_*idh 6

使用 mod

f x | x `mod` 5 == 0 = x `div` 5
f x | x `mod` 6 == 0 = x `div` 6
f _ = 2
Run Code Online (Sandbox Code Playgroud)

如果是int,则返回x/5,否则,如果是int,则返回x/6,否则返回2.