unionWith f ((timex,x):xs) ((timey,y):ys) | timex == timey = (timex,f x y) : unionWith f xs ys | timex < timey = (timex,x) : unionWith f xs ((timey,y):ys) | timex > timey = (timey,y) : unionWith f ((timex,x):xs) ys