Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module contains miscellaneous helper utils for rote actions in the Cli monad, like resolving a relative path to an absolute path, per the current path.
Synopsis
- getCurrentPath :: Cli Absolute
- getCurrentProjectName :: Cli ProjectName
- getCurrentProjectBranchName :: Cli ProjectBranchName
- getCurrentProjectPath :: Cli ProjectPath
- resolvePath :: Path -> Cli ProjectPath
- resolvePath' :: Path' -> Cli ProjectPath
- resolvePath'ToAbsolute :: Path' -> Cli Absolute
- resolveSplit' :: (Path', a) -> Cli (ProjectPath, a)
- getCurrentProjectAndBranch :: Cli (ProjectAndBranch Project ProjectBranch)
- getCurrentProjectBranch :: Cli ProjectBranch
- resolveAbsBranchId :: AbsBranchId -> Cli (Branch IO)
- resolveAbsBranchIdV2 :: (forall void. Output -> Transaction void) -> ProjectAndBranch Project ProjectBranch -> AbsBranchId -> Transaction (Branch Transaction)
- resolveBranchId :: BranchId -> Cli (Branch IO)
- resolveBranchIdToAbsBranchId :: BranchId -> Cli AbsBranchId
- resolveShortCausalHash :: ShortCausalHash -> Cli (Branch IO)
- getCurrentProjectRoot :: Cli (Branch IO)
- getCurrentProjectRoot0 :: Cli (Branch0 IO)
- getCurrentBranch :: Cli (Branch IO)
- getCurrentBranch0 :: Cli (Branch0 IO)
- getProjectBranchRoot :: ProjectBranch -> Cli (Branch IO)
- getBranchFromProjectPath :: ProjectPath -> Cli (Branch IO)
- getBranch0FromProjectPath :: ProjectPath -> Cli (Branch0 IO)
- getMaybeBranchFromProjectPath :: ProjectPath -> Cli (Maybe (Branch IO))
- getMaybeBranch0FromProjectPath :: ProjectPath -> Cli (Maybe (Branch0 IO))
- expectBranchAtPath :: Path -> Cli (Branch IO)
- expectBranchAtPath' :: Path' -> Cli (Branch IO)
- expectBranch0AtPath :: Path -> Cli (Branch0 IO)
- expectBranch0AtPath' :: Path' -> Cli (Branch0 IO)
- assertNoBranchAtPath' :: Path' -> Cli ()
- branchExistsAtPath' :: Path' -> Cli Bool
- stepAt' :: Text -> (ProjectPath, Branch0 IO -> Cli (Branch0 IO)) -> Cli Bool
- stepAt :: Text -> (ProjectPath, Branch0 IO -> Branch0 IO) -> Cli ()
- stepAtM :: Text -> (ProjectPath, Branch0 IO -> IO (Branch0 IO)) -> Cli ()
- stepManyAt :: ProjectBranch -> Text -> [(Absolute, Branch0 IO -> Branch0 IO)] -> Cli ()
- stepManyAtM :: ProjectBranch -> Text -> [(Absolute, Branch0 IO -> IO (Branch0 IO))] -> Cli ()
- updateProjectBranchRoot :: ProjectBranch -> Text -> (Branch IO -> Cli (Branch IO, r)) -> Cli r
- updateProjectBranchRoot_ :: ProjectBranch -> Text -> (Branch IO -> Branch IO) -> Cli ()
- updateAtM :: Text -> ProjectPath -> (Branch IO -> Cli (Branch IO)) -> Cli Bool
- updateAt :: Text -> ProjectPath -> (Branch IO -> Branch IO) -> Cli Bool
- updateAndStepAt :: (Foldable f, Foldable g, Functor g) => Text -> ProjectBranch -> f (Absolute, Branch IO -> Branch IO) -> g (Absolute, Branch0 IO -> Branch0 IO) -> Cli ()
- getTermsAt :: (ProjectPath, HQSegment) -> Cli (Set Referent)
- getTypesAt :: (ProjectPath, HQSegment) -> Cli (Set TypeReference)
- defaultPatchPath :: Split'
- getPatchAt :: Split' -> Cli Patch
- getLatestFile :: Cli (Maybe (FilePath, Bool))
- getLatestParsedFile :: Cli (Maybe (UnisonFile Symbol Ann))
- getNamesFromLatestFile :: Cli Names
- getTermFromLatestParsedFile :: HashQualified Name -> Cli (Maybe (Term Symbol Ann))
- expectLatestFile :: Cli (FilePath, Bool)
- expectLatestParsedFile :: Cli (UnisonFile Symbol Ann)
- getLatestTypecheckedFile :: Cli (Maybe (TypecheckedUnisonFile Symbol Ann))
- expectLatestTypecheckedFile :: Cli (TypecheckedUnisonFile Symbol Ann)
- makeParsingEnv :: ProjectPath -> Names -> Cli (ParsingEnv Transaction)
Paths
getCurrentPath :: Cli Absolute Source #
Get the current path relative to the current project.
resolvePath :: Path -> Cli ProjectPath Source #
Resolve a Path
(interpreted as relative) to a Path.Absolute
, per the current path.
resolvePath' :: Path' -> Cli ProjectPath Source #
Resolve a Path'
to a Path.Absolute
, per the current path.
resolveSplit' :: (Path', a) -> Cli (ProjectPath, a) Source #
Resolve a path split, per the current path.
Project and branch resolution
Branches
Resolving branch identifiers
resolveAbsBranchId :: AbsBranchId -> Cli (Branch IO) Source #
Resolve an AbsBranchId
to the corresponding Branch IO
, or fail if no such branch hash is found. (Non-existent
branches by path are OK - the empty branch will be returned).
resolveAbsBranchIdV2 :: (forall void. Output -> Transaction void) -> ProjectAndBranch Project ProjectBranch -> AbsBranchId -> Transaction (Branch Transaction) Source #
V2 version of resolveAbsBranchId2
.
resolveBranchId :: BranchId -> Cli (Branch IO) Source #
Resolve a BranchId
to the corresponding Branch IO
, or fail if no such branch hash is found. (Non-existent
branches by path are OK - the empty branch will be returned).
resolveBranchIdToAbsBranchId :: BranchId -> Cli AbsBranchId Source #
Resolve a BranchId
to an AbsBranchId
.
resolveShortCausalHash :: ShortCausalHash -> Cli (Branch IO) Source #
Resolve a ShortCausalHash
to the corresponding Branch IO
, or fail if no such branch hash is found.
Getting/setting branches
getProjectBranchRoot :: ProjectBranch -> Cli (Branch IO) Source #
getBranchFromProjectPath :: ProjectPath -> Cli (Branch IO) Source #
Get the branch at an absolute path from the project root.
getBranch0FromProjectPath :: ProjectPath -> Cli (Branch0 IO) Source #
Get the branch0 at an absolute path.
getMaybeBranchFromProjectPath :: ProjectPath -> Cli (Maybe (Branch IO)) Source #
Get the maybe-branch at an absolute path.
getMaybeBranch0FromProjectPath :: ProjectPath -> Cli (Maybe (Branch0 IO)) Source #
Get the maybe-branch0 at an absolute path.
expectBranchAtPath :: Path -> Cli (Branch IO) Source #
Get the branch at a relative path, or return early if there's no such branch.
expectBranchAtPath' :: Path' -> Cli (Branch IO) Source #
Get the branch at an absolute or relative path, or return early if there's no such branch.
expectBranch0AtPath :: Path -> Cli (Branch0 IO) Source #
Get the branch0 at a relative path, or return early if there's no such branch.
expectBranch0AtPath' :: Path' -> Cli (Branch0 IO) Source #
Get the branch0 at an absolute or relative path, or return early if there's no such branch.
assertNoBranchAtPath' :: Path' -> Cli () Source #
Assert that there's "no branch" at an absolute or relative path, or return early if there is one, where "no branch" means either there's actually no branch, or there is a branch whose head is empty (i.e. it may have a history, but no current terms/types etc).
branchExistsAtPath' :: Path' -> Cli Bool Source #
Check if there's a branch at an absolute or relative path
"no branch" means either there's actually no branch, or there is a branch whose head is empty (i.e. it may have a history, but no current terms/types etc).
Updating branches
stepManyAtM :: ProjectBranch -> Text -> [(Absolute, Branch0 IO -> IO (Branch0 IO))] -> Cli () Source #
updateProjectBranchRoot :: ProjectBranch -> Text -> (Branch IO -> Cli (Branch IO, r)) -> Cli r Source #
updateProjectBranchRoot_ :: ProjectBranch -> Text -> (Branch IO -> Branch IO) -> Cli () Source #
updateAtM :: Text -> ProjectPath -> (Branch IO -> Cli (Branch IO)) -> Cli Bool Source #
Update a branch at the given path, returning True
if
an update occurred and false otherwise
updateAt :: Text -> ProjectPath -> (Branch IO -> Branch IO) -> Cli Bool Source #
Update a branch at the given path, returning True
if
an update occurred and false otherwise
updateAndStepAt :: (Foldable f, Foldable g, Functor g) => Text -> ProjectBranch -> f (Absolute, Branch IO -> Branch IO) -> g (Absolute, Branch0 IO -> Branch0 IO) -> Cli () Source #
Terms
getTermsAt :: (ProjectPath, HQSegment) -> Cli (Set Referent) Source #
Types
getTypesAt :: (ProjectPath, HQSegment) -> Cli (Set TypeReference) Source #
Patches
Default patch
defaultPatchPath :: Split' Source #
The default patch path.
Getting patches
getPatchAt :: Split' -> Cli Patch Source #
Get the patch at a path, or the empty patch if there's no such patch.
Latest touched Unison file
getLatestParsedFile :: Cli (Maybe (UnisonFile Symbol Ann)) Source #
Get the latest parsed unison file.
getNamesFromLatestFile :: Cli Names Source #
Gets the names from the latest typechecked unison file, or latest parsed file if it didn't typecheck.
getTermFromLatestParsedFile :: HashQualified Name -> Cli (Maybe (Term Symbol Ann)) Source #
Returns a parsed term (potentially with free variables) from the latest file. This term will refer to other terms in the file by vars, not by hash. Used to implement rewriting and other refactorings on the current file.
getLatestTypecheckedFile :: Cli (Maybe (TypecheckedUnisonFile Symbol Ann)) Source #
Get the latest typechecked unison file.
expectLatestTypecheckedFile :: Cli (TypecheckedUnisonFile Symbol Ann) Source #
Get the latest typechecked unison file, or return early if there isn't one.
Parsing env
makeParsingEnv :: ProjectPath -> Names -> Cli (ParsingEnv Transaction) Source #