I have started to learn Haskell yesterday, so you can consider me a complete newbie.
I wanted a list of prime numbers, so I stated:
multiples max reihe = [ x | x <- [reihe*2,reihe * 3..max], x<= max ]
notPrimes max = [ truncate x | x <- concat [ multiples max reihe | reihe <- [2..(max/2)]]]
primes max = [ x | x <- [2..max] , elem x (notPrimes max) ]
The first snippet is a function which returns all multiples of reihe not exceeding max.
The second is a function which returns all non-primes except 1 up to the specified maximum.
The last snippet does not work, and I don't understand why. If I evaluate elem x (notPrimes max) with an arbitrary value of x I get an answer, but this "filter" throws an error:
<interactive>:47:1: error:
* Ambiguous type variable `a0' arising from a use of `print'
prevents the constraint `(Show a0)' from being solved.
Probable fix: use a type annotation to specify what `a0' should be.
These potential instances exist:
instance Show Ordering -- Defined in `GHC.Show'
instance Show a => Show (Maybe a) -- Defined in `GHC.Show'
instance Show Integer -- Defined in `GHC.Show'
...plus 23 others
...plus 15 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
* In a stmt of an interactive GHCi command: print it