--takes an infinite list of infinite lists and gives an infinite list of finite lists
diagonalize :: [[a]] -> [[a]]
diagonalize = foldr f []
  where
    f :: [a] -> [[a]] -> [[a]]
    f []     ys = [] : ys
    f (x:xs) ys = [x] : zipWithDefaults (:) (: []) id xs ys
diagonalize :: [[a]] -> [[a]]
diagonalize = foldr f []
  where
    f :: [a] -> [[a]] -> [[a]]
    f []     ys = [] : ys
    f (x:xs) ys = [x] : zipWithDefaults (:) (: []) id xs ys
diagonalize = foldr f []
  where
    f :: [a] -> [[a]] -> [[a]]
    f []     ys = [] : ys
    f (x:xs) ys = [x] : zipWithDefaults (:) (: []) id xs ys