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 ( Int -> PristineType -> ShowS
[PristineType] -> ShowS
PristineType -> String
(Int -> PristineType -> ShowS)
-> (PristineType -> String)
-> ([PristineType] -> ShowS)
-> Show PristineType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PristineType] -> ShowS
$cshowList :: [PristineType] -> ShowS
show :: PristineType -> String
$cshow :: PristineType -> String
showsPrec :: Int -> PristineType -> ShowS
$cshowsPrec :: Int -> PristineType -> ShowS
Show, PristineType -> PristineType -> Bool
(PristineType -> PristineType -> Bool)
-> (PristineType -> PristineType -> Bool) -> Eq PristineType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PristineType -> PristineType -> Bool
$c/= :: PristineType -> PristineType -> Bool
== :: PristineType -> PristineType -> Bool
$c== :: PristineType -> PristineType -> Bool
Eq )
data Repository (rt :: RepoType) (p :: * -> * -> *) wRecordedstate wUnrecordedstate wTentativestate =
Repo !String !RepoFormat !PristineType Cache deriving ( Int
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> ShowS
[Repository rt p wRecordedstate wUnrecordedstate wTentativestate]
-> ShowS
Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String
(Int
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> ShowS)
-> (Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String)
-> ([Repository
rt p wRecordedstate wUnrecordedstate wTentativestate]
-> ShowS)
-> Show
(Repository rt p wRecordedstate wUnrecordedstate wTentativestate)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
Int
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> ShowS
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
[Repository rt p wRecordedstate wUnrecordedstate wTentativestate]
-> ShowS
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String
showList :: [Repository rt p wRecordedstate wUnrecordedstate wTentativestate]
-> ShowS
$cshowList :: forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
[Repository rt p wRecordedstate wUnrecordedstate wTentativestate]
-> ShowS
show :: Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String
$cshow :: forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String
showsPrec :: Int
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> ShowS
$cshowsPrec :: forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
Int
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> ShowS
Show )
type role Repository nominal nominal nominal nominal nominal
repoLocation :: Repository rt p wR wU wT -> String
repoLocation :: Repository rt p wR wU wT -> String
repoLocation (Repo String
loc RepoFormat
_ PristineType
_ Cache
_) = String
loc
withRepoLocation :: Repository rt p wR wU wT -> IO a -> IO a
withRepoLocation :: Repository rt p wR wU wT -> IO a -> IO a
withRepoLocation Repository rt p wR wU wT
repo = String -> IO a -> IO a
forall p a. FilePathLike p => p -> IO a -> IO a
withCurrentDirectory (Repository rt p wR wU wT -> String
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
Repository rt p wRecordedstate wUnrecordedstate wTentativestate
-> String
repoLocation Repository rt p wR wU wT
repo)
repoFormat :: Repository rt p wR wU wT -> RepoFormat
repoFormat :: Repository rt p wR wU wT -> RepoFormat
repoFormat (Repo String
_ RepoFormat
fmt PristineType
_ Cache
_) = RepoFormat
fmt
repoPristineType :: Repository rt p wR wU wT -> PristineType
repoPristineType :: Repository rt p wR wU wT -> PristineType
repoPristineType (Repo String
_ RepoFormat
_ PristineType
pr Cache
_) = PristineType
pr
repoCache :: Repository rt p wR wU wT -> Cache
repoCache :: Repository rt p wR wU wT -> Cache
repoCache (Repo String
_ RepoFormat
_ PristineType
_ Cache
c) = Cache
c
modifyCache :: (Cache -> Cache) -> Repository rt p wR wU wT -> Repository rt p wR wU wT
modifyCache :: (Cache -> Cache)
-> Repository rt p wR wU wT -> Repository rt p wR wU wT
modifyCache Cache -> Cache
g (Repo String
l RepoFormat
f PristineType
p Cache
c) = String
-> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
String
-> RepoFormat
-> PristineType
-> Cache
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
Repo String
l RepoFormat
f PristineType
p (Cache -> Cache
g Cache
c)
unsafeCoerceRepoType :: Repository rt p wR wU wT -> Repository rt' p wR wU wT
unsafeCoerceRepoType :: Repository rt p wR wU wT -> Repository rt' p wR wU wT
unsafeCoerceRepoType = Repository rt p wR wU wT -> Repository rt' p wR wU wT
forall a b. a -> b
unsafeCoerce
unsafeCoercePatchType :: Repository rt p wR wU wT -> Repository rt p' wR wU wT
unsafeCoercePatchType :: Repository rt p wR wU wT -> Repository rt p' wR wU wT
unsafeCoercePatchType = Repository rt p wR wU wT -> Repository rt p' wR wU wT
forall a b. a -> b
unsafeCoerce
unsafeCoerceR :: Repository rt p wR wU wT -> Repository rt p wR' wU wT
unsafeCoerceR :: Repository rt p wR wU wT -> Repository rt p wR' wU wT
unsafeCoerceR = Repository rt p wR wU wT -> Repository rt p wR' wU wT
forall a b. a -> b
unsafeCoerce
unsafeCoerceU :: Repository rt p wR wU wT -> Repository rt p wR wU' wT
unsafeCoerceU :: Repository rt p wR wU wT -> Repository rt p wR wU' wT
unsafeCoerceU = Repository rt p wR wU wT -> Repository rt p wR wU' wT
forall a b. a -> b
unsafeCoerce
unsafeCoerceT :: Repository rt p wR wU wT -> Repository rt p wR wU wT'
unsafeCoerceT :: Repository rt p wR wU wT -> Repository rt p wR wU wT'
unsafeCoerceT = Repository rt p wR wU wT -> Repository rt p wR wU wT'
forall a b. a -> b
unsafeCoerce
mkRepo :: String -> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT
mkRepo :: String
-> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT
mkRepo = String
-> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT
forall (rt :: RepoType) (p :: * -> * -> *) wRecordedstate
wUnrecordedstate wTentativestate.
String
-> RepoFormat
-> PristineType
-> Cache
-> Repository rt p wRecordedstate wUnrecordedstate wTentativestate
Repo