unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Cli.MonadUtils

Description

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

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

getCurrentProjectRoot :: Cli (Branch IO) Source #

Get the root branch.

getCurrentProjectRoot0 :: Cli (Branch0 IO) Source #

Get the root branch0.

getCurrentBranch :: Cli (Branch IO) Source #

Get the current branch.

getCurrentBranch0 :: Cli (Branch0 IO) Source #

Get the current branch0.

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

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

Terms

Types

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