module Darcs.Repository.InternalTypes ( Repository, PristineType(..)
, repoCache, modifyCache
, repoFormat
, repoLocation
, withRepoLocation
, repoPristineType
, unsafeCoerceRepoType
, unsafeCoercePatchType
, unsafeCoerceR
, unsafeCoerceU
, unsafeCoerceT
, mkRepo
) where
import Darcs.Prelude
import Darcs.Repository.Cache ( Cache )
import Darcs.Repository.Format ( RepoFormat )
import Darcs.Patch ( RepoType )
import Darcs.Util.File ( withCurrentDirectory )
import Unsafe.Coerce ( unsafeCoerce )
data PristineType
= NoPristine
| PlainPristine
| HashedPristine
deriving ( Show, Eq )
data Repository (rt :: RepoType) (p :: * -> * -> *) wRecordedstate wUnrecordedstate wTentativestate =
Repo !String !RepoFormat !PristineType Cache deriving ( Show )
type role Repository nominal nominal nominal nominal nominal
repoLocation :: Repository rt p wR wU wT -> String
repoLocation (Repo loc _ _ _) = loc
withRepoLocation :: Repository rt p wR wU wT -> IO a -> IO a
withRepoLocation repo = withCurrentDirectory (repoLocation repo)
repoFormat :: Repository rt p wR wU wT -> RepoFormat
repoFormat (Repo _ fmt _ _) = fmt
repoPristineType :: Repository rt p wR wU wT -> PristineType
repoPristineType (Repo _ _ pr _) = pr
repoCache :: Repository rt p wR wU wT -> Cache
repoCache (Repo _ _ _ c) = c
modifyCache :: (Cache -> Cache) -> Repository rt p wR wU wT -> Repository rt p wR wU wT
modifyCache g (Repo l f p c) = Repo l f p (g c)
unsafeCoerceRepoType :: Repository rt p wR wU wT -> Repository rt' p wR wU wT
unsafeCoerceRepoType = unsafeCoerce
unsafeCoercePatchType :: Repository rt p wR wU wT -> Repository rt p' wR wU wT
unsafeCoercePatchType = unsafeCoerce
unsafeCoerceR :: Repository rt p wR wU wT -> Repository rt p wR' wU wT
unsafeCoerceR = unsafeCoerce
unsafeCoerceU :: Repository rt p wR wU wT -> Repository rt p wR wU' wT
unsafeCoerceU = unsafeCoerce
unsafeCoerceT :: Repository rt p wR wU wT -> Repository rt p wR wU wT'
unsafeCoerceT = unsafeCoerce
mkRepo :: String -> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT
mkRepo = Repo