turtle
                                
                                
                                
                                    turtle copied to clipboard
                            
                            
                            
                        Abstracting command return types
I'm finding my code is doing a lot of this:
o1 <- shellStrict cmd1 empty
case o1 of
  (ExitFailure, stderr) -> handle err
  (ExitSuccess, stdout) -> do
    
    o2 <- shellStrict cmd2 empty
    case o2 of
      (ExitFailure, stderr) -> handle err
      (ExitSuccess, stdout) -> do
            ...
I'd like to abstract this and am wondering why Tuple is used for procStrict/shellStrict instead of the Either monad, as with inprocWithErr/inshellWithErr?
I'm not a shell programmer, so I very well may be missing the intended use case.
Here's a related discussion in the context of shell:
Stack Overflow - Composing ExitCodes in Turtle.
Shell supports IO, which means it supports IO exceptions. You can always throw a meaningful exception in case of ExitFailure and then catch it a few levels up.
I have the same use case but I actually need to stream the result of the first command when it succeeds ...
So I need to do something like  inshell cmd empty & shell jq but I want to retry to first command in case of a 'ExitFailure'.
I don't see how I can achieve this without using shellStrict. Any idea ?