I tried:
composites=[c|c<-[4..], any (\p->(c`mod`p == 0)) (takeWhile (< (sqrt c)) primes)]
primes=2:[p|p<-[3..], not p `elem` (takeWhile (<p) composites)]
and got:
pad.hs:1:19:
No instance for (Num Bool) arising from the literal `4'
Possible fix: add an instance declaration for (Num Bool)
In the expression: 4
In the expression: [4 .. ]
In a stmt of a list comprehension: c <- [4 .. ]
pad.hs:1:30:
No instance for (Integral Bool) arising from a use of `divisible'
Possible fix: add an instance declaration for (Integral Bool)
In the first argument of `any', namely `(divisible c)'
In the expression: any (divisible c) (factors c)
In a stmt of a list comprehension: any (divisible c) (factors c)
pad.hs:3:43:
No instance for (Floating Bool) arising from a use of `sqrt'
Possible fix: add an instance declaration for (Floating Bool)
In the second argument of `(<)', namely `sqrt c'
In the first argument of `takeWhile', namely `(< sqrt c)'
In the expression: takeWhile (< sqrt c) primes
Failed, modules loaded: none.
I think that it is confused as to what type of number it is dealing with, but I am not sure. Any tips?