fibs = 1 : 1 : zipWith (+) fibs (tail fibs)

primes :: [Integer]
primes = 2 : filter (isPrime primes) [3,5..]  where
   isPrime (p:ps) n
     | mod n p == 0 = False
     | p*p > n      = True
     | otherwise    = isPrime ps n
   isPrime [] _ = False 

-- scan indices source
scan indices source = scan' indices 1 source
  where
    scan' [] _ _ = []
    scan' _ _ [] = []
    scan' (i:is) n (x:xs) | n == i = x:scan' is n (x:xs)
    scan' (i:is) n (x:xs) | n < i  = scan' (i:is) (n+1) xs
    scan' (i:is) n (x:xs)          = scan' is n (x:xs)

partC = scan primes fibs
partD = scan fibs primes

n = 30

main = do 
     print (take n fibs)
     print (take n primes)
     print (take n partC)
     print (take n partD)

