{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
import Control.Monad.Free (Free, foldFree)
recovering :: a -> a
recovering = id
class Robust f where
isIdempotent :: f a -> Bool
foldRobust :: forall f g a. Robust f => Monad g => (forall x. f x -> g x) -> Free f a -> g a
foldRobust interpret = foldFree interpret'
where
interpret' :: f x -> g x
interpret' action
| isIdempotent action = recovering $ interpret action
| otherwise = interpret action
main :: IO ()
main = putStrLn "Hello World!"