私は次の実用的な定義を持っています:
{-# LANGUAGE ScopedTypeVariables #-}
module Control.Retry where
import Prelude hiding (catch)
import Control.Exception
import Control.Concurrent
retrying [] action = action
retrying (i:is) action = catch action processError
where
processError (e :: IOException) = threadDelay i >> retrying is action
好奇心から、ScopedTypeVariables
プラグマを使用せずにこれを再実装するにはどうすればよいのか、まったくできないのか、そしてprocessError
指定するとコンパイルできなくなるため、推論された型宣言は実際には何なのか疑問に思いますprocessError :: IOException -> IO a
。