| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Unison.Project
Contents
Description
Projects.
The syntax-related parsing code (what makes a valid project name, etc) could conceivably be moved into a different package, but for now we have just defined the one blessed project/branch name syntax that we allow.
Synopsis
- data ProjectName
- projectNameUserSlug :: ProjectName -> Maybe Text
- projectNameToUserProjectSlugs :: ProjectName -> (Text, Text)
- prependUserSlugToProjectName :: Text -> ProjectName -> ProjectName
- isValidNewProjectName :: ProjectName -> Bool
- data ProjectBranchName
- projectBranchNameUserSlug :: ProjectBranchName -> Maybe Text
- projectBranchNameToValidProjectBranchNameText :: ProjectBranchName -> TextBuilder
- data ProjectBranchNameKind
- classifyProjectBranchName :: ProjectBranchName -> ProjectBranchNameKind
- data ProjectBranchNameOrLatestRelease
- data ProjectBranchSpecifier a where
- data ProjectAndBranch a b = ProjectAndBranch {}
- projectAndBranchNamesParser :: ProjectBranchSpecifier branch -> Parsec Void Text (These ProjectName branch)
- fullyQualifiedProjectAndBranchNamesParser :: Parsec Void Text (ProjectAndBranch ProjectName ProjectBranchName)
- projectAndOptionalBranchParser :: ProjectBranchSpecifier branch -> Parsec Void Text (ProjectAndBranch ProjectName (Maybe branch))
- branchWithOptionalProjectParser :: Parsec Void Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName)
- data ProjectAndBranchNames
- projectAndBranchNamesParser2 :: Parsec Void Text ProjectAndBranchNames
- projectNameParser :: Parsec Void Text (ProjectName, Bool)
- projectBranchNameParser :: Bool -> Parsec Void Text ProjectBranchName
- defaultBranchName :: ProjectBranchName
- data Semver = Semver !Int !Int !Int
Documentation
data ProjectName #
The name of a project.
Instances
projectNameUserSlug :: ProjectName -> Maybe Text Source #
Get the user slug at the beginning of a project name, if there is one.
>>>projectNameUserSlug "@arya/lens"Just "arya"
>>>projectNameUserSlug "lens"Nothing
projectNameToUserProjectSlugs :: ProjectName -> (Text, Text) Source #
Parse a "@arya/lens" into the "arya" and "lens" parts.
If there's no "arya" part, returns the empty string there.
>>>projectNameToUserProjectSlugs (UnsafeProjectName "@arya/lens")("arya","lens")
>>>projectNameToUserProjectSlugs (UnsafeProjectName "lens")("","lens")
prependUserSlugToProjectName :: Text -> ProjectName -> ProjectName Source #
Prepend a user slug to a project name, if it doesn't already have one.
>>>prependUserSlugToProjectName "arya" "lens""@arya/lens"
>>>prependUserSlugToProjectName "runar" "@unison/base""@unison/base"
>>>prependUserSlugToProjectName "???invalid???" "@unison/base""@unison/base"
data ProjectBranchName #
The name of a branch of a project.
Instances
| Generic ProjectBranchName | |||||
Defined in Unison.Core.Project Associated Types
Methods from :: ProjectBranchName -> Rep ProjectBranchName x # to :: Rep ProjectBranchName x -> ProjectBranchName # | |||||
| Show ProjectBranchName | |||||
Defined in Unison.Core.Project Methods showsPrec :: Int -> ProjectBranchName -> ShowS # show :: ProjectBranchName -> String # showList :: [ProjectBranchName] -> ShowS # | |||||
| Eq ProjectBranchName | |||||
Defined in Unison.Core.Project Methods (==) :: ProjectBranchName -> ProjectBranchName -> Bool # (/=) :: ProjectBranchName -> ProjectBranchName -> Bool # | |||||
| Ord ProjectBranchName | |||||
Defined in Unison.Core.Project Methods compare :: ProjectBranchName -> ProjectBranchName -> Ordering # (<) :: ProjectBranchName -> ProjectBranchName -> Bool # (<=) :: ProjectBranchName -> ProjectBranchName -> Bool # (>) :: ProjectBranchName -> ProjectBranchName -> Bool # (>=) :: ProjectBranchName -> ProjectBranchName -> Bool # max :: ProjectBranchName -> ProjectBranchName -> ProjectBranchName # min :: ProjectBranchName -> ProjectBranchName -> ProjectBranchName # | |||||
| From ProjectBranchName Text Source # | |||||
Defined in Unison.Project Methods from :: ProjectBranchName -> Text # | |||||
| TryFrom Text ProjectBranchName Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text ProjectBranchName) ProjectBranchName # | |||||
| TryFrom Text (These ProjectName ProjectBranchName) Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text (These ProjectName ProjectBranchName)) (These ProjectName ProjectBranchName) # | |||||
| TryFrom Text (ProjectAndBranch ProjectName ProjectBranchName) Source # | Attempt to parse a project and branch name from a string where both are required. | ||||
Defined in Unison.Project | |||||
| TryFrom Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName))) (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) # | |||||
| TryFrom Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName)) (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) # | |||||
| From (These ProjectName ProjectBranchName) Text Source # | |||||
Defined in Unison.Project Methods from :: These ProjectName ProjectBranchName -> Text # | |||||
| From (ProjectAndBranch ProjectName ProjectBranchName) Text Source # | |||||
Defined in Unison.Project Methods from :: ProjectAndBranch ProjectName ProjectBranchName -> Text # | |||||
| From (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Text Source # |
| ||||
Defined in Unison.Project Methods from :: ProjectAndBranch ProjectName (Maybe ProjectBranchName) -> Text # | |||||
| From (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Text Source # |
| ||||
Defined in Unison.Project Methods from :: ProjectAndBranch (Maybe ProjectName) ProjectBranchName -> Text # | |||||
| type Rep ProjectBranchName | |||||
Defined in Unison.Core.Project type Rep ProjectBranchName = D1 ('MetaData "ProjectBranchName" "Unison.Core.Project" "unison-core-0.0.0-1VWfQyRJkVMKYBxkNy6zmW" 'True) (C1 ('MetaCons "UnsafeProjectBranchName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) | |||||
projectBranchNameUserSlug :: ProjectBranchName -> Maybe Text Source #
Get the user slug at the beginning of a project branch name, if there is one.
>>>projectBranchNameUserSlug "@arya/topic"Just "arya"
>>>projectBranchNameUserSlug "topic"Nothing
projectBranchNameToValidProjectBranchNameText :: ProjectBranchName -> TextBuilder Source #
Mangle a project branch name into a text fragment that is itself a valid project branch name.
>>>TextBuilder.toText (projectBranchNameToValidProjectBranchNameText (UnsafeProjectBranchName "@arya/topic"))"arya-topic"
>>>TextBuilder.toText (projectBranchNameToValidProjectBranchNameText (UnsafeProjectBranchName "releases/drafts/1.2.3"))"releases-drafts-1-2-3"
>>>TextBuilder.toText (projectBranchNameToValidProjectBranchNameText (UnsafeProjectBranchName "releases/1.2.3"))"releases-1-2-3"
>>>TextBuilder.toText (projectBranchNameToValidProjectBranchNameText (UnsafeProjectBranchName "topic"))"topic"
data ProjectBranchNameKind Source #
Though a branch name is just a flat string, we have logic that handles certain strings specially.
A branch's name indicates it is exactly one of the following:
- A contributor branch like "@arya/topic"
- A draft release branch like "releasesdrafts1.2.3"
- A release branch like "releases/1.2.3"
- None of the above, like "topic"
Note these classifications are only tied to the branch's (mutable) name, and are not really otherwise indicative of much.
For instance,
- The existence of a local "releases/1.2.3" branch does not necessarily imply the existence of some remote release version "1.2.3".
- The existence of a local "
arya/topicbranch does not necessarily imply the existence of some remote "arya" user made some "topic" branch at some point.
That said, we do try to make the system mostly make sense by rejecting certain inputs (e.g. you should not be able to easily create a local branch called "releases/1.2.3" out of thin air; you should have to clone it from somewhere). But ultimately, again, branch names are best thought of as opaque, flat strings.
classifyProjectBranchName :: ProjectBranchName -> ProjectBranchNameKind Source #
Classify a project branch name.
>>>classifyProjectBranchName "@arya/topic"Contributor "arya" "topic"
>>>classifyProjectBranchName "releases/drafts/1.2.3"DraftRelease (Semver 1 2 3)
>>>classifyProjectBranchName "releases/1.2.3"Release (Semver 1 2 3)
>>>classifyProjectBranchName "topic"NothingSpecial
data ProjectBranchNameOrLatestRelease Source #
A project branch name, or the latest release of its project.
Constructors
| ProjectBranchNameOrLatestRelease'LatestRelease | |
| ProjectBranchNameOrLatestRelease'Name !ProjectBranchName |
Instances
| Show ProjectBranchNameOrLatestRelease Source # | |
Defined in Unison.Project Methods showsPrec :: Int -> ProjectBranchNameOrLatestRelease -> ShowS # | |
| Eq ProjectBranchNameOrLatestRelease Source # | |
Defined in Unison.Project | |
| TryFrom Text (ProjectAndBranch ProjectName (Maybe ProjectBranchNameOrLatestRelease)) Source # | |
Defined in Unison.Project | |
data ProjectBranchSpecifier a where Source #
How a project branch can be specified.
Constructors
| ProjectBranchSpecifier'Name :: ProjectBranchSpecifier ProjectBranchName | By name. |
| ProjectBranchSpecifier'NameOrLatestRelease :: ProjectBranchSpecifier ProjectBranchNameOrLatestRelease | By name, or "the latest release" |
data ProjectAndBranch a b #
A generic data structure that contains information about a project and a branch in that project.
Constructors
| ProjectAndBranch | |
Instances
| Bifoldable ProjectAndBranch | |||||
Defined in Unison.Core.Project Methods bifold :: Monoid m => ProjectAndBranch m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> ProjectAndBranch a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> ProjectAndBranch a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> ProjectAndBranch a b -> c # | |||||
| Bifunctor ProjectAndBranch | |||||
Defined in Unison.Core.Project Methods bimap :: (a -> b) -> (c -> d) -> ProjectAndBranch a c -> ProjectAndBranch b d # first :: (a -> b) -> ProjectAndBranch a c -> ProjectAndBranch b c # second :: (b -> c) -> ProjectAndBranch a b -> ProjectAndBranch a c # | |||||
| Bitraversable ProjectAndBranch | |||||
Defined in Unison.Core.Project Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> ProjectAndBranch a b -> f (ProjectAndBranch c d) # | |||||
| TryFrom Text (ProjectAndBranch ProjectName ProjectBranchName) Source # | Attempt to parse a project and branch name from a string where both are required. | ||||
Defined in Unison.Project | |||||
| TryFrom Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName))) (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) # | |||||
| TryFrom Text (ProjectAndBranch ProjectName (Maybe ProjectBranchNameOrLatestRelease)) Source # | |||||
Defined in Unison.Project | |||||
| TryFrom Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Source # | |||||
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName)) (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) # | |||||
| Functor (ProjectAndBranch a) | |||||
Defined in Unison.Core.Project Methods fmap :: (a0 -> b) -> ProjectAndBranch a a0 -> ProjectAndBranch a b # (<$) :: a0 -> ProjectAndBranch a b -> ProjectAndBranch a a0 # | |||||
| Generic (ProjectAndBranch a b) | |||||
Defined in Unison.Core.Project Associated Types
Methods from :: ProjectAndBranch a b -> Rep (ProjectAndBranch a b) x # to :: Rep (ProjectAndBranch a b) x -> ProjectAndBranch a b # | |||||
| (Show a, Show b) => Show (ProjectAndBranch a b) | |||||
Defined in Unison.Core.Project Methods showsPrec :: Int -> ProjectAndBranch a b -> ShowS # show :: ProjectAndBranch a b -> String # showList :: [ProjectAndBranch a b] -> ShowS # | |||||
| (Eq a, Eq b) => Eq (ProjectAndBranch a b) | |||||
Defined in Unison.Core.Project Methods (==) :: ProjectAndBranch a b -> ProjectAndBranch a b -> Bool # (/=) :: ProjectAndBranch a b -> ProjectAndBranch a b -> Bool # | |||||
| From (ProjectAndBranch ProjectName ProjectBranchName) Text Source # | |||||
Defined in Unison.Project Methods from :: ProjectAndBranch ProjectName ProjectBranchName -> Text # | |||||
| From (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Text Source # |
| ||||
Defined in Unison.Project Methods from :: ProjectAndBranch ProjectName (Maybe ProjectBranchName) -> Text # | |||||
| From (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Text Source # |
| ||||
Defined in Unison.Project Methods from :: ProjectAndBranch (Maybe ProjectName) ProjectBranchName -> Text # | |||||
| type Rep (ProjectAndBranch a b) | |||||
Defined in Unison.Core.Project type Rep (ProjectAndBranch a b) = D1 ('MetaData "ProjectAndBranch" "Unison.Core.Project" "unison-core-0.0.0-1VWfQyRJkVMKYBxkNy6zmW" 'False) (C1 ('MetaCons "ProjectAndBranch" 'PrefixI 'True) (S1 ('MetaSel ('Just "project") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "branch") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b))) | |||||
projectAndBranchNamesParser :: ProjectBranchSpecifier branch -> Parsec Void Text (These ProjectName branch) Source #
fullyQualifiedProjectAndBranchNamesParser :: Parsec Void Text (ProjectAndBranch ProjectName ProjectBranchName) Source #
Parse a fully specified myproject/mybranch name.
>>>import Text.Megaparsec (parseMaybe)>>>parseMaybe fullyQualifiedProjectAndBranchNamesParser ("myproject/mybranch" :: Text)Just (ProjectAndBranch {project = UnsafeProjectName "myproject", branch = UnsafeProjectBranchName "mybranch"})
projectAndOptionalBranchParser :: ProjectBranchSpecifier branch -> Parsec Void Text (ProjectAndBranch ProjectName (Maybe branch)) Source #
branchWithOptionalProjectParser :: Parsec Void Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Source #
data ProjectAndBranchNames Source #
Sometimes, it's convenient (to users) if we defer interpreting certain names (like "foo") as a project name or branch name, instead leaving it up to a command handler to handle the ambiguity.
For example, we might want "switch foo" to switch to either the project "foo", or the branch "foo", or complain if both exist.
This type is useful for those situtations.
Constructors
| ProjectAndBranchNames'Ambiguous ProjectName ProjectBranchName | |
| ProjectAndBranchNames'Unambiguous (These ProjectName ProjectBranchName) |
Instances
| Show ProjectAndBranchNames Source # | |
Defined in Unison.Project Methods showsPrec :: Int -> ProjectAndBranchNames -> ShowS # show :: ProjectAndBranchNames -> String # showList :: [ProjectAndBranchNames] -> ShowS # | |
| Eq ProjectAndBranchNames Source # | |
Defined in Unison.Project Methods (==) :: ProjectAndBranchNames -> ProjectAndBranchNames -> Bool # (/=) :: ProjectAndBranchNames -> ProjectAndBranchNames -> Bool # | |
| TryFrom Text ProjectAndBranchNames Source # | |
Defined in Unison.Project Methods tryFrom :: Text -> Either (TryFromException Text ProjectAndBranchNames) ProjectAndBranchNames # | |
Semver
Orphan instances
| From ProjectBranchName Text Source # | |
Methods from :: ProjectBranchName -> Text # | |
| From ProjectName Text Source # | |
Methods from :: ProjectName -> Text # | |
| TryFrom Text ProjectBranchName Source # | |
Methods tryFrom :: Text -> Either (TryFromException Text ProjectBranchName) ProjectBranchName # | |
| TryFrom Text ProjectName Source # | |
Methods tryFrom :: Text -> Either (TryFromException Text ProjectName) ProjectName # | |
| TryFrom Text (These ProjectName ProjectBranchName) Source # | |
Methods tryFrom :: Text -> Either (TryFromException Text (These ProjectName ProjectBranchName)) (These ProjectName ProjectBranchName) # | |
| TryFrom Text (ProjectAndBranch ProjectName ProjectBranchName) Source # | Attempt to parse a project and branch name from a string where both are required. |
| TryFrom Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Source # | |
Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch ProjectName (Maybe ProjectBranchName))) (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) # | |
| TryFrom Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Source # | |
Methods tryFrom :: Text -> Either (TryFromException Text (ProjectAndBranch (Maybe ProjectName) ProjectBranchName)) (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) # | |
| From (These ProjectName ProjectBranchName) Text Source # | |
Methods from :: These ProjectName ProjectBranchName -> Text # | |
| From (ProjectAndBranch ProjectName ProjectBranchName) Text Source # | |
Methods from :: ProjectAndBranch ProjectName ProjectBranchName -> Text # | |
| From (ProjectAndBranch ProjectName (Maybe ProjectBranchName)) Text Source # |
|
Methods from :: ProjectAndBranch ProjectName (Maybe ProjectBranchName) -> Text # | |
| From (ProjectAndBranch (Maybe ProjectName) ProjectBranchName) Text Source # |
|
Methods from :: ProjectAndBranch (Maybe ProjectName) ProjectBranchName -> Text # | |