{-# LANGUAGE StrictData #-}
module Data.VCS.Ignore.Repo
( Repo(..)
, RepoError(..)
)
where
import Control.Exception ( Exception(..) )
import Control.Monad.Catch ( MonadThrow )
import Control.Monad.IO.Class ( MonadIO )
import Data.Text ( Text )
import qualified Data.Text as T
import Data.VCS.Ignore.Types ( fromVCSIgnoreError
, toVCSIgnoreError
)
class Repo r where
repoName :: r
-> Text
repoRoot :: r
-> FilePath
scanRepo :: (MonadIO m, MonadThrow m)
=> FilePath
-> m r
isIgnored :: MonadIO m
=> r
-> FilePath
-> m Bool
data RepoError = InvalidRepo FilePath Text
deriving (RepoError -> RepoError -> Bool
(RepoError -> RepoError -> Bool)
-> (RepoError -> RepoError -> Bool) -> Eq RepoError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepoError -> RepoError -> Bool
$c/= :: RepoError -> RepoError -> Bool
== :: RepoError -> RepoError -> Bool
$c== :: RepoError -> RepoError -> Bool
Eq, Int -> RepoError -> ShowS
[RepoError] -> ShowS
RepoError -> String
(Int -> RepoError -> ShowS)
-> (RepoError -> String)
-> ([RepoError] -> ShowS)
-> Show RepoError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepoError] -> ShowS
$cshowList :: [RepoError] -> ShowS
show :: RepoError -> String
$cshow :: RepoError -> String
showsPrec :: Int -> RepoError -> ShowS
$cshowsPrec :: Int -> RepoError -> ShowS
Show)
instance Exception RepoError where
displayException :: RepoError -> String
displayException = RepoError -> String
displayException'
fromException :: SomeException -> Maybe RepoError
fromException = SomeException -> Maybe RepoError
forall e. Exception e => SomeException -> Maybe e
fromVCSIgnoreError
toException :: RepoError -> SomeException
toException = RepoError -> SomeException
forall e. Exception e => e -> SomeException
toVCSIgnoreError
displayException' :: RepoError -> String
displayException' :: RepoError -> String
displayException' (InvalidRepo String
path Text
reason) =
[String] -> String
forall a. Monoid a => [a] -> a
mconcat [String
"Path '", String
path, String
"' is not a valid repository: ", Text -> String
T.unpack Text
reason]