module HaskellWorks.CabalCache.Store ( cleanupStorePath, ) where import Control.Monad.Catch (MonadCatch) import HaskellWorks.Prelude import qualified Control.Monad.Oops as OO import qualified HaskellWorks.CabalCache.IO.Lazy as IO import qualified System.Directory as IO cleanupStorePath :: () => MonadIO m => MonadCatch m => FilePath -> ExceptT (OO.Variant e) m () cleanupStorePath :: forall (m :: * -> *) (e :: [*]). (MonadIO m, MonadCatch m) => FilePath -> ExceptT (Variant e) m () cleanupStorePath FilePath packageStorePath = do Bool pathExists <- IO Bool -> ExceptT (Variant e) m Bool forall a. IO a -> ExceptT (Variant e) m a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO Bool -> ExceptT (Variant e) m Bool) -> IO Bool -> ExceptT (Variant e) m Bool forall a b. (a -> b) -> a -> b $ FilePath -> IO Bool IO.doesPathExist FilePath packageStorePath Bool -> ExceptT (Variant e) m () -> ExceptT (Variant e) m () forall (f :: * -> *). Applicative f => Bool -> f () -> f () when Bool pathExists (ExceptT (Variant e) m () -> ExceptT (Variant e) m ()) -> ExceptT (Variant e) m () -> ExceptT (Variant e) m () forall a b. (a -> b) -> a -> b $ ExceptT (Variant e) m () -> ExceptT (Variant e) m () forall (f :: * -> *) a. Functor f => f a -> f () void (ExceptT (Variant e) m () -> ExceptT (Variant e) m ()) -> ExceptT (Variant e) m () -> ExceptT (Variant e) m () forall a b. (a -> b) -> a -> b $ FilePath -> ExceptT (Variant e) m () forall (m :: * -> *) (e :: [*]). (MonadCatch m, MonadIO m) => FilePath -> ExceptT (Variant e) m () IO.removePathRecursive FilePath packageStorePath