Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- loadCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe CausalHash)
- expectCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction CausalHash
- loadCausalBranchAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe (CausalBranch Transaction))
- loadBranchAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe (Branch Transaction))
- saveBranch :: HashHandle -> CausalBranch Transaction -> Transaction (BranchObjectId, CausalHashId)
- saveBranchV3 :: HashHandle -> CausalBranchV3 Transaction -> Transaction (BranchObjectId, CausalHashId)
- loadCausalBranchByCausalHash :: CausalHash -> Transaction (Maybe (CausalBranch Transaction))
- expectCausalBranchByCausalHash :: CausalHash -> Transaction (CausalBranch Transaction)
- expectBranchByCausalHashId :: CausalHashId -> Transaction (Branch Transaction)
- expectBranchByBranchHash :: BranchHash -> Transaction (Branch Transaction)
- expectBranchByBranchHashId :: BranchHashId -> Transaction (Branch Transaction)
- expectNamespaceStatsByHash :: BranchHash -> Transaction NamespaceStats
- expectNamespaceStatsByHashId :: BranchHashId -> Transaction NamespaceStats
- tryGetSquashResult :: BranchHash -> Transaction (Maybe CausalHash)
- saveSquashResult :: BranchHash -> CausalHash -> Transaction ()
- saveTermComponent :: HashHandle -> Maybe ByteString -> Hash -> [(Term Symbol, Type Symbol)] -> Transaction ObjectId
- loadTermComponent :: Hash -> MaybeT Transaction [(Term Symbol, Type Symbol)]
- loadTermByReference :: Id -> MaybeT Transaction (Term Symbol)
- loadTypeOfTermByTermReference :: Id -> MaybeT Transaction (Type Symbol)
- saveDeclComponent :: HashHandle -> Maybe ByteString -> Hash -> [Decl Symbol] -> Transaction ObjectId
- loadDeclComponent :: Hash -> MaybeT Transaction [Decl Symbol]
- loadDeclByReference :: Id -> MaybeT Transaction (Decl Symbol)
- expectDeclByReference :: Id -> Transaction (Decl Symbol)
- expectDeclNumConstructors :: Id -> Transaction Int
- expectDeclTypeById :: Id -> Transaction DeclType
- getCycleLen :: Hash -> Transaction (Maybe Word64)
- savePatch :: HashHandle -> PatchHash -> Patch -> Transaction PatchObjectId
- expectPatch :: PatchObjectId -> Transaction Patch
- objectExistsForHash :: Hash -> Transaction Bool
- saveWatch :: WatchKind -> Id -> Term Symbol -> Transaction ()
- loadWatch :: WatchKind -> Id -> MaybeT Transaction (Term Symbol)
- listWatches :: WatchKind -> Transaction [Id]
- clearWatches :: Transaction ()
- before :: CausalHash -> CausalHash -> Transaction (Maybe Bool)
- lca :: CausalHash -> CausalHash -> Transaction (Maybe CausalHash)
- componentReferencesByPrefix :: ObjectType -> Text -> Maybe Pos -> Transaction [Id]
- termReferentsByPrefix :: Text -> Maybe Word64 -> Transaction [Id]
- declReferentsByPrefix :: Text -> Maybe Pos -> Maybe ConstructorId -> Transaction [(Hash, Pos, DeclType, [ConstructorId])]
- causalHashesByPrefix :: ShortCausalHash -> Transaction (Set CausalHash)
- directDependenciesOfScope :: DefnsF Set TermReferenceId TypeReferenceId -> Transaction (DefnsF Set TermReference TypeReference)
- dependents :: DependentsSelector -> Reference -> Transaction (Set Id)
- dependentsOfComponent :: Hash -> Transaction (Set Id)
- directDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId)
- transitiveDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId)
- addTypeToIndexForTerm :: Id -> Reference -> Transaction ()
- termsHavingType :: Reference -> Transaction (Set Id)
- filterTermsByReferenceHavingType :: TypeReference -> [Id] -> Transaction [Id]
- filterTermsByReferentHavingType :: TypeReference -> [Id] -> Transaction [Id]
- addTypeMentionsToIndexForTerm :: Id -> Set Reference -> Transaction ()
- termsMentioningType :: Reference -> Transaction (Set Id)
- allNamesInPerspective :: NamesPerspective -> Transaction NamesInPerspective
- data NamesInPerspective = NamesInPerspective {}
- data NamesPerspective = NamesPerspective {}
- termNamesForRefWithinNamespace :: NamesPerspective -> Referent -> Maybe ReversedName -> Transaction [ReversedName]
- typeNamesForRefWithinNamespace :: NamesPerspective -> Reference -> Maybe ReversedName -> Transaction [ReversedName]
- termNamesBySuffix :: NamesPerspective -> ReversedName -> Transaction [NamedRef (Referent, Maybe ConstructorType)]
- typeNamesBySuffix :: NamesPerspective -> ReversedName -> Transaction [NamedRef Reference]
- termRefsForExactName :: NamesPerspective -> ReversedName -> Transaction [NamedRef (Referent, Maybe ConstructorType)]
- typeRefsForExactName :: NamesPerspective -> ReversedName -> Transaction [NamedRef Reference]
- recursiveTermNameSearch :: NamesPerspective -> Referent -> Transaction (Maybe ReversedName)
- recursiveTypeNameSearch :: NamesPerspective -> Reference -> Transaction (Maybe ReversedName)
- checkBranchHashNameLookupExists :: BranchHash -> Transaction Bool
- buildNameLookupForBranchHash :: Maybe BranchHash -> BranchHash -> ((([NamedRef (Referent, Maybe ConstructorType)], [NamedRef Referent]) -> ([NamedRef Reference], [NamedRef Reference]) -> Transaction ()) -> Transaction ()) -> Transaction ()
- associateNameLookupMounts :: BranchHash -> [(PathSegments, BranchHash)] -> Transaction ()
- longestMatchingTermNameForSuffixification :: NamesPerspective -> NamedRef Referent -> Transaction (Maybe (NamedRef (Referent, Maybe ConstructorType)))
- longestMatchingTypeNameForSuffixification :: NamesPerspective -> NamedRef Reference -> Transaction (Maybe (NamedRef Reference))
- deleteNameLookupsExceptFor :: Set BranchHash -> Transaction ()
- fuzzySearchDefinitions :: Bool -> NamesPerspective -> Int -> [Text] -> Transaction ([NamedRef (Referent, Maybe ConstructorType)], [NamedRef Reference])
- namesPerspectiveForRootAndPath :: BranchHash -> PathSegments -> Transaction NamesPerspective
- expectProjectAndBranchNames :: ProjectId -> ProjectBranchId -> Transaction (ProjectName, ProjectBranchName)
- expectProjectBranchHead :: ProjectId -> ProjectBranchId -> Transaction CausalHash
- getDeprecatedRootReflog :: Int -> Transaction [Entry CausalHash Text]
- getProjectReflog :: Int -> ProjectId -> Transaction [Entry Project ProjectBranch CausalHash]
- getProjectBranchReflog :: Int -> ProjectBranchId -> Transaction [Entry Project ProjectBranch CausalHash]
- getGlobalReflog :: Int -> Transaction [Entry Project ProjectBranch CausalHash]
- appendProjectReflog :: Entry ProjectId ProjectBranchId CausalHash -> Transaction ()
- expectDbBranch :: BranchObjectId -> Transaction DbBranch
- saveDbBranch :: HashHandle -> BranchHash -> NamespaceStats -> DbBranchV -> Transaction BranchObjectId
- saveDbBranchUnderHashId :: HashHandle -> BranchHashId -> NamespaceStats -> DbBranchV -> Transaction BranchObjectId
- expectDbPatch :: PatchObjectId -> Transaction Patch
- saveDbPatch :: HashHandle -> PatchHash -> PatchFormat -> Transaction PatchObjectId
- expectDbBranchByCausalHashId :: CausalHashId -> Transaction DbBranch
- namespaceStatsForDbBranch :: DbBranchV -> Transaction NamespaceStats
- c2sReferenceId :: Id -> Transaction Id
- c2sReferentId :: Id -> Transaction Id
- diffPatch :: LocalPatch -> LocalPatch -> LocalPatchDiff
- decodeTermElementWithType :: Pos -> ByteString -> Either DecodeError (LocalIds, Term, Type)
- loadTermWithTypeByReference :: Id -> MaybeT Transaction (Term Symbol, Type Symbol)
- s2cTermWithType :: LocalIds -> Term -> Type -> Transaction (Term Symbol, Type Symbol)
- s2cDecl :: LocalIds -> Decl Symbol -> Transaction (Decl Symbol)
- declReferencesByPrefix :: Text -> Maybe Word64 -> Transaction [Id]
- namespaceHashesByPrefix :: ShortNamespaceHash -> Transaction (Set BranchHash)
- derivedDependencies :: Id -> Transaction (Set Id)
- data BranchV m
- data DbBranchV
branches
loadCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe CausalHash) Source #
Load the causal hash at the given path from the provided root, if Nothing, use the codebase root.
expectCausalHashAtPath :: CausalHash -> [NameSegment] -> Transaction CausalHash Source #
Expect the causal hash at the given path from the provided root, if Nothing, use the codebase root.
loadCausalBranchAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe (CausalBranch Transaction)) Source #
loadBranchAtPath :: CausalHash -> [NameSegment] -> Transaction (Maybe (Branch Transaction)) Source #
saveBranch :: HashHandle -> CausalBranch Transaction -> Transaction (BranchObjectId, CausalHashId) Source #
saveBranchV3 :: HashHandle -> CausalBranchV3 Transaction -> Transaction (BranchObjectId, CausalHashId) Source #
loadCausalBranchByCausalHash :: CausalHash -> Transaction (Maybe (CausalBranch Transaction)) Source #
expectNamespaceStatsByHash :: BranchHash -> Transaction NamespaceStats Source #
Looks up statistics for a given branch, if none exist, we compute them and save them then return them.
expectNamespaceStatsByHashId :: BranchHashId -> Transaction NamespaceStats Source #
Looks up statistics for a given branch, if none exist, we compute them and save them then return them.
tryGetSquashResult :: BranchHash -> Transaction (Maybe CausalHash) Source #
Get the causal hash which would be the result of squashing the provided branch hash. Returns Nothing if we haven't computed it before.
saveSquashResult :: BranchHash -> CausalHash -> Transaction () Source #
Saves the result of a squash
terms
:: HashHandle | |
-> Maybe ByteString | The serialized term component if we already have it e.g. via sync |
-> Hash | term component hash |
-> [(Term Symbol, Type Symbol)] | term component |
-> Transaction ObjectId |
loadTermComponent :: Hash -> MaybeT Transaction [(Term Symbol, Type Symbol)] Source #
loadTermByReference :: Id -> MaybeT Transaction (Term Symbol) Source #
decls
saveDeclComponent :: HashHandle -> Maybe ByteString -> Hash -> [Decl Symbol] -> Transaction ObjectId Source #
loadDeclComponent :: Hash -> MaybeT Transaction [Decl Symbol] Source #
loadDeclByReference :: Id -> MaybeT Transaction (Decl Symbol) Source #
expectDeclByReference :: Id -> Transaction (Decl Symbol) Source #
terms/decls
getCycleLen :: Hash -> Transaction (Maybe Word64) Source #
patches
savePatch :: HashHandle -> PatchHash -> Patch -> Transaction PatchObjectId Source #
test for stuff in codebase
watch expression cache
loadWatch :: WatchKind -> Id -> MaybeT Transaction (Term Symbol) Source #
returns Nothing if the expression isn't cached.
listWatches :: WatchKind -> Transaction [Id] Source #
clearWatches :: Transaction () Source #
Delete all watches that were put by putWatch
.
indexes
nearest common ancestor
before :: CausalHash -> CausalHash -> Transaction (Maybe Bool) Source #
lca :: CausalHash -> CausalHash -> Transaction (Maybe CausalHash) Source #
prefix index
componentReferencesByPrefix :: ObjectType -> Text -> Maybe Pos -> Transaction [Id] Source #
termReferentsByPrefix :: Text -> Maybe Word64 -> Transaction [Id] Source #
declReferentsByPrefix :: Text -> Maybe Pos -> Maybe ConstructorId -> Transaction [(Hash, Pos, DeclType, [ConstructorId])] Source #
dependents index
directDependenciesOfScope :: DefnsF Set TermReferenceId TypeReferenceId -> Transaction (DefnsF Set TermReference TypeReference) Source #
dependents :: DependentsSelector -> Reference -> Transaction (Set Id) Source #
returns a list of known definitions referencing r
dependentsOfComponent :: Hash -> Transaction (Set Id) Source #
returns a list of known definitions referencing h
directDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId) Source #
`directDependentsWithinScope scope query` returns all direct dependents of query
that are in scope
(not
including query
itself).
transitiveDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId) Source #
`transitiveDependentsWithinScope scope query` returns all transitive dependents of query
that are in scope
(not
including query
itself).
type index
addTypeToIndexForTerm :: Id -> Reference -> Transaction () Source #
termsHavingType :: Reference -> Transaction (Set Id) Source #
filterTermsByReferenceHavingType :: TypeReference -> [Id] -> Transaction [Id] Source #
filterTermsByReferentHavingType :: TypeReference -> [Id] -> Transaction [Id] Source #
type mentions index
addTypeMentionsToIndexForTerm :: Id -> Set Reference -> Transaction () Source #
termsMentioningType :: Reference -> Transaction (Set Id) Source #
name lookup index
allNamesInPerspective :: NamesPerspective -> Transaction NamesInPerspective Source #
Get all the term and type names for the given namespace from the lookup table. Requires that an index for this branch hash already exists, which is currently only true on Share.
data NamesInPerspective Source #
data NamesPerspective Source #
Any time we need to lookup or search names we need to know what the scope of that search should be. This can be complicated to keep track of, so this is a helper type to make it easy to pass around.
You should use namesPerspectiveForRootAndPath
to construct this type.
E.g. if we're in loose code, we need to search the correct name lookup for the user's perspective. If their perspective is "myprojects.json.latest.lib.base.data.List", we need to search names using the name index mounted at "myprojects.json.latest.lib.base".
The NamesPerspective representing this viewpoint would be:
@
NamesPerspective
{ nameLookupBranchHashId = #libbasehash
, pathToMountedNameLookup = ["myprojects.json", "latest", "lib", "base"]
, relativePerspective = ["data", List]
}
@
NamesPerspective | |
|
Instances
Show NamesPerspective Source # | |
Defined in U.Codebase.Sqlite.Operations showsPrec :: Int -> NamesPerspective -> ShowS # show :: NamesPerspective -> String # showList :: [NamesPerspective] -> ShowS # | |
Eq NamesPerspective Source # | |
Defined in U.Codebase.Sqlite.Operations (==) :: NamesPerspective -> NamesPerspective -> Bool # (/=) :: NamesPerspective -> NamesPerspective -> Bool # |
termNamesForRefWithinNamespace :: NamesPerspective -> Referent -> Maybe ReversedName -> Transaction [ReversedName] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of a names for a given Referent.
typeNamesForRefWithinNamespace :: NamesPerspective -> Reference -> Maybe ReversedName -> Transaction [ReversedName] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of a names for a given Reference, with an optional required suffix.
termNamesBySuffix :: NamesPerspective -> ReversedName -> Transaction [NamedRef (Referent, Maybe ConstructorType)] Source #
termRefsForExactName :: NamesPerspective -> ReversedName -> Transaction [NamedRef (Referent, Maybe ConstructorType)] Source #
typeRefsForExactName :: NamesPerspective -> ReversedName -> Transaction [NamedRef Reference] Source #
recursiveTermNameSearch :: NamesPerspective -> Referent -> Transaction (Maybe ReversedName) Source #
Searches all dependencies transitively looking for the provided ref within the
provided namespace.
Prefer termNamesForRefWithinNamespace
in most cases.
This is slower and only necessary when resolving the name of refs when you don't know which
dependency it may exist in.
Searching transitive dependencies is exponential so we want to replace this with a more efficient approach as soon as possible.
Note: this returns the first name it finds by searching in order of: Names in the current namespace, then names in the current namespace's dependencies, then through the current namespace's dependencies' dependencies, etc.
recursiveTypeNameSearch :: NamesPerspective -> Reference -> Transaction (Maybe ReversedName) Source #
Searches all dependencies transitively looking for the provided ref within the provided
namespace.
Prefer typeNamesForRefWithinNamespace
in most cases.
This is slower and only necessary when resolving the name of references when you don't know which
dependency it may exist in.
Searching transitive dependencies is exponential so we want to replace this with a more efficient approach as soon as possible.
Note: this returns the first name it finds by searching in order of: Names in the current namespace, then names in the current namespace's dependencies, then through the current namespace's dependencies' dependencies, etc.
checkBranchHashNameLookupExists :: BranchHash -> Transaction Bool Source #
Check whether we've already got an index for a given branch hash.
buildNameLookupForBranchHash :: Maybe BranchHash -> BranchHash -> ((([NamedRef (Referent, Maybe ConstructorType)], [NamedRef Referent]) -> ([NamedRef Reference], [NamedRef Reference]) -> Transaction ()) -> Transaction ()) -> Transaction () Source #
Apply a set of name updates to an existing index.
associateNameLookupMounts :: BranchHash -> [(PathSegments, BranchHash)] -> Transaction () Source #
Save a list of (mount-path, branch hash) mounts for the provided name lookup index branch hash.
E.g. associateNameLookupMounts #roothash [(["lib", "base"], #basehash)]
longestMatchingTermNameForSuffixification :: NamesPerspective -> NamedRef Referent -> Transaction (Maybe (NamedRef (Referent, Maybe ConstructorType))) Source #
Get the name within the provided namespace that has the longest matching suffix with the provided name, but a different ref. This is a bit of a hack but allows us to shortcut suffixification. We can clean this up if we make a custom PPE type just for sqlite pretty printing, but for now this works fine.
longestMatchingTypeNameForSuffixification :: NamesPerspective -> NamedRef Reference -> Transaction (Maybe (NamedRef Reference)) Source #
Get the name within the provided namespace that has the longest matching suffix with the provided name, but a different ref. This is a bit of a hack but allows us to shortcut suffixification. We can clean this up if we make a custom PPE type just for sqlite pretty printing, but for now this works fine.
deleteNameLookupsExceptFor :: Set BranchHash -> Transaction () Source #
Delete any name lookup that's not in the provided list.
This can be used to garbage collect unreachable name lookups.
fuzzySearchDefinitions Source #
:: Bool | |
-> NamesPerspective | |
-> Int | Will return at most n terms and n types; i.e. max number of results is 2n |
-> [Text] | |
-> Transaction ([NamedRef (Referent, Maybe ConstructorType)], [NamedRef Reference]) |
Search for term or type names which contain the provided list of segments in order. Search is case insensitive.
namesPerspectiveForRootAndPath :: BranchHash -> PathSegments -> Transaction NamesPerspective Source #
Determine which nameLookup is the closest parent of the provided perspective.
Returns (rootBranchId of the closest parent index, namespace that index is mounted at, location of the perspective within the mounted namespace)
E.g. If your namespace is "lib.distributed.lib.base.data.List", you'd get back (rootBranchId of the lib.distributed.lib.base name lookup, "lib.distributed.lib.base", "data.List")
Or if your namespace is "subnamespace.user", you'd get back (the rootBranchId you provided, "", "subnamespace.user")
Projects
expectProjectAndBranchNames :: ProjectId -> ProjectBranchId -> Transaction (ProjectName, ProjectBranchName) Source #
reflog
getDeprecatedRootReflog :: Int -> Transaction [Entry CausalHash Text] Source #
Gets the specified number of reflog entries in chronological order, most recent first.
getProjectReflog :: Int -> ProjectId -> Transaction [Entry Project ProjectBranch CausalHash] Source #
Gets the specified number of reflog entries for the given project in chronological order, most recent first.
getProjectBranchReflog :: Int -> ProjectBranchId -> Transaction [Entry Project ProjectBranch CausalHash] Source #
Gets the specified number of reflog entries for the specified ProjectBranch in chronological order, most recent first.
getGlobalReflog :: Int -> Transaction [Entry Project ProjectBranch CausalHash] Source #
Gets the specified number of reflog entries in chronological order, most recent first.
low-level stuff
saveDbBranch :: HashHandle -> BranchHash -> NamespaceStats -> DbBranchV -> Transaction BranchObjectId Source #
Save a DbBranch
, given its hash (which the caller is expected to produce from the branch).
Note: long-standing question: should this package depend on the hashing package? (If so, we would only need to take the DbBranch, and hash internally).
saveDbBranchUnderHashId :: HashHandle -> BranchHashId -> NamespaceStats -> DbBranchV -> Transaction BranchObjectId Source #
Variant of saveDbBranch
that might be preferred by callers that already have a hash id, not a hash.
saveDbPatch :: HashHandle -> PatchHash -> PatchFormat -> Transaction PatchObjectId Source #
expectDbBranchByCausalHashId :: CausalHashId -> Transaction DbBranch Source #
Expect a branch value given its causal hash id.
somewhat unexpectedly unused definitions
c2sReferenceId :: Id -> Transaction Id Source #
c2sReferentId :: Id -> Transaction Id Source #
diffPatch :: LocalPatch -> LocalPatch -> LocalPatchDiff Source #
produces a diff diff = full - ref; full = diff + ref
decodeTermElementWithType :: Pos -> ByteString -> Either DecodeError (LocalIds, Term, Type) Source #
declReferencesByPrefix :: Text -> Maybe Word64 -> Transaction [Id] Source #
derivedDependencies :: Id -> Transaction (Set Id) Source #
returns empty set for unknown inputs; doesn't distinguish between term and decl