Type any - (a -> Bool) -> [a] -> Bool , so it takes a predicate and a collection. Therefore, you should rewrite your last case, for example,
is_prime n = not $ any (\k -> n `mod` k /= 0) [2 .. ceiling $ sqrt $ fromIntegral n]
fromIntegral necessary, since the type sqrt Floating a => a -> a , and your n is an integer. Subsequently, without ceiling second argument to any would be Floating t => [t] . This will break because calling mod , whose type is Integral a => a -> a -> a , on non-integer types is illegal.
If you want to find some other implementations, I can recommend, for example, this discussion .
source share