compactIp (r0@(Range a b):((Range b' c):xs))
  | inRange r0 b' = compactIp (Range a (max b c) : xs)
  | otherwise = r0 : compactIp ((Range b' c) : xs)
compactIp (r0@(Range a b):((Range b' c):xs))
  | inRange r0 b' = compactIp (Range a (max b c) : xs)
  | otherwise = r0 : compactIp ((Range b' c) : xs)
compactIp (r0@(Range a b):((Range b' c):xs))
  | inRange r0 b' = compactIp (Range a (max b c) : xs)
  | otherwise = r0 : compactIp ((Range b' c) : xs)