shrink :: TestConfig -> [ShrinkOperation] -> Interaction -> TestError -> ([ProcCommand] -> [[Response]] -> [(String,Bool)]) -> IO TestError
shrink c sops tr err f = go (shrinkCommands sops tr)
  where
    go [] | SrkRemoveInteraction `elem` sops = shrink c [SrkRemoveMessages] tr err f
    go []        = return err 
    go (tr':trs) = do
        me <- testCommands c (map snd tr') f 
        case me of
          Just err' -> shrink c sops tr' err' f
          Nothing   -> go trs
shrink :: TestConfig -> [ShrinkOperation] -> Interaction -> TestError -> ([ProcCommand] -> [[Response]] -> [(String,Bool)]) -> IO TestError
shrink c sops tr err f = go (shrinkCommands sops tr)
  where
    go [] | SrkRemoveInteraction `elem` sops = shrink c [SrkRemoveMessages] tr err f
    go []        = return err 
    go (tr':trs) = do
        me <- testCommands c (map snd tr') f 
        case me of
          Just err' -> shrink c sops tr' err' f
          Nothing   -> go trs
shrink c sops tr err f = go (shrinkCommands sops tr)
  where
    go [] | SrkRemoveInteraction `elem` sops = shrink c [SrkRemoveMessages] tr err f
    go []        = return err 
    go (tr':trs) = do
        me <- testCommands c (map snd tr') f 
        case me of
          Just err' -> shrink c sops tr' err' f
          Nothing   -> go trs