waitFor cond chan = do
  n <- atomically $ readTChan chan
  if (cond n) then return n else waitFor cond chan
waitFor cond chan = do
  n <- atomically $ readTChan chan
  if (cond n) then return n else waitFor cond chan
waitFor cond chan = do
  n <- atomically $ readTChan chan
  if (cond n) then return n else waitFor cond chan