I have a code that looks like this:
retryOnTimeout :: IO a -> IO a retryOnTimeout action = catch action $ \ResponseTimeout -> do putStrLn "Timed out. Trying again." threadDelay 5000000 action
The problem is that there are many other HttpException constructors, and I would like to keep trying again no matter which error it is. Now, if I replaced ResponseTimeout with _ , then I will get a compilation error because it cannot throw an exception type.
I really don't want to provide a type signature for the exception handler.
I know this is not so much duplication, but adding a case for _ seems wrong, because it looks like a saying: if the exception is ResponseTimeout, then do x, but if the exception is something else, do the same. Is there a concise way to use the template, but still let the compiler know what type it is?
source share