Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data BranchRelativePath
- parseBranchRelativePath :: String -> Either (Pretty ColorText) BranchRelativePath
- branchRelativePathParser :: Parsec Void Text BranchRelativePath
- parseIncrementalBranchRelativePath :: String -> Either (Pretty ColorText) IncrementalBranchRelativePath
- data IncrementalBranchRelativePath
- toText :: BranchRelativePath -> Text
Documentation
data BranchRelativePath Source #
BranchPathInCurrentProject ProjectBranchName Absolute | A path rooted at some specified branch/project |
QualifiedBranchPath ProjectName ProjectBranchName Absolute | |
UnqualifiedPath Path' | A path which is relative to the user's current location. |
Instances
Show BranchRelativePath Source # | |
Defined in Unison.CommandLine.BranchRelativePath showsPrec :: Int -> BranchRelativePath -> ShowS # show :: BranchRelativePath -> String # showList :: [BranchRelativePath] -> ShowS # | |
Eq BranchRelativePath Source # | |
Defined in Unison.CommandLine.BranchRelativePath (==) :: BranchRelativePath -> BranchRelativePath -> Bool # (/=) :: BranchRelativePath -> BranchRelativePath -> Bool # | |
From BranchRelativePath Text Source # |
|
Defined in Unison.CommandLine.BranchRelativePath from :: BranchRelativePath -> Text # |
parseBranchRelativePath :: String -> Either (Pretty ColorText) BranchRelativePath Source #
Strings without colons are parsed as loose code paths. A path with a colon may specify: 1. A project and branch 2. Only a branch, in which case the project is assumed to be the current project 3. Only a path, in which case the path is rooted at the branch root
Specifying only a project is not allowed.
>>>
parseBranchRelativePath "foo"
Right (UnqualifiedPath foo)>>>
parseBranchRelativePath "foo/bar:"
Right (QualifiedBranchPath (UnsafeProjectName "foo") (UnsafeProjectBranchName "bar") .)>>>
parseBranchRelativePath "foo/bar:.some.path"
Right (QualifiedBranchPath (UnsafeProjectName "foo") (UnsafeProjectBranchName "bar") .some.path)>>>
parseBranchRelativePath "/bar:.some.path"
Right (BranchPathInCurrentProject (UnsafeProjectBranchName "bar") .some.path)>>>
parseBranchRelativePath ":.some.path"
Right (UnqualifiedPath .some.path)
>>>
parseBranchRelativePath ".branch"
Right (UnqualifiedPath .branch)
parseIncrementalBranchRelativePath :: String -> Either (Pretty ColorText) IncrementalBranchRelativePath Source #
>>>
parseIncrementalBranchRelativePath "foo"
Right (ProjectOrRelative "foo" foo)
>>>
parseIncrementalBranchRelativePath "foo/bar:"
Right (IncompletePath (Left (ProjectAndBranch {project = UnsafeProjectName "foo", branch = UnsafeProjectBranchName "bar"})) Nothing)
>>>
parseIncrementalBranchRelativePath "foo/bar:some.path"
Right (IncompletePath (Left (ProjectAndBranch {project = UnsafeProjectName "foo", branch = UnsafeProjectBranchName "bar"})) (Just some.path))
>>>
parseIncrementalBranchRelativePath "/bar:some.path"
Right (IncompletePath (Right (UnsafeProjectBranchName "bar")) (Just some.path))
>>>
parseIncrementalBranchRelativePath ":some.path"
Right (PathRelativeToCurrentBranch some.path)
>>>
parseIncrementalBranchRelativePath "/branch"
Right (IncompleteBranch Nothing (Just (UnsafeProjectBranchName "branch")))
>>>
parseIncrementalBranchRelativePath "/"
Right (IncompleteBranch Nothing Nothing)
data IncrementalBranchRelativePath Source #
ProjectOrPath' Text Path' | no dots, slashes, or colons, so could be a project name or a single path segment |
OnlyPath' Path' | dots, no slashes or colons, must be a relative or absolute path |
IncompleteProject ProjectName | valid project, no slash |
IncompleteBranch (Maybe ProjectName) (Maybe ProjectBranchName) | valid project/branch, slash, no colon |
IncompletePath (Either (ProjectAndBranch ProjectName ProjectBranchName) ProjectBranchName) (Maybe Absolute) | valid project/branch, with colon |
PathRelativeToCurrentBranch Absolute |
Instances
toText :: BranchRelativePath -> Text Source #