ReadonlyStoreEffects: Operate over rooted and valid paths.

This commit is contained in:
Shea Levy 2018-04-27 04:48:29 -07:00
parent f26c6edd26
commit 02e1adf263
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27

View File

@ -43,7 +43,23 @@ data Path = Path !(Digest PathHashAlgo) !PathName
-- | Read-only interactions with a store.
--
-- 'rootedPath': A path plus a witness to the fact that the path is
-- reachable from a root whose liftime is at least as long as the
-- 'rootedPath' reference itself, when the implementation supports
-- this.
--
-- 'validPath': A 'rootedPath' plus a witness to the fact that the
-- path is valid. On implementations that support temporary roots,
-- this implies that the path will remain valid so long as the
-- reference is held.
--
-- 'm': The monad the effects operate in.
data ReadonlyStoreEffects m = ReadonlyStoreEffects
{ isValidPath :: !(Path -> m Bool) -- ^ Is the given path valid?
}
data ReadonlyStoreEffects rootedPath validPath m =
ReadonlyStoreEffects
{ -- | Project out the underlying 'Path' from a 'rootedPath'
fromRootedPath :: !(rootedPath -> Path)
, -- | Project out the underlying 'rootedPath' from a 'validPath'
fromValidPath :: !(validPath -> rootedPath)
, -- | Is the given path valid?
isValidPath :: !(rootedPath -> m (Maybe validPath))
}