module Unison.Cli.NamesUtils
( currentNames,
currentProjectRootNames,
projectBranchNames,
)
where
import U.Codebase.Sqlite.ProjectBranch (ProjectBranch)
import Unison.Cli.Monad (Cli)
import Unison.Cli.MonadUtils qualified as Cli
import Unison.Codebase.Branch qualified as Branch
import Unison.Codebase.Branch.Names qualified as Branch
import Unison.Names (Names)
currentNames :: Cli Names
currentNames :: Cli Names
currentNames = do
Branch0 IO -> Names
forall (m :: * -> *). Branch0 m -> Names
Branch.toNames (Branch0 IO -> Names) -> Cli (Branch0 IO) -> Cli Names
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Cli (Branch0 IO)
Cli.getCurrentBranch0
currentProjectRootNames :: Cli Names
currentProjectRootNames :: Cli Names
currentProjectRootNames = do
Branch0 IO -> Names
forall (m :: * -> *). Branch0 m -> Names
Branch.toNames (Branch0 IO -> Names) -> Cli (Branch0 IO) -> Cli Names
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Cli (Branch0 IO)
Cli.getCurrentProjectRoot0
projectBranchNames :: ProjectBranch -> Cli Names
projectBranchNames :: ProjectBranch -> Cli Names
projectBranchNames ProjectBranch
pb = do
Branch0 IO -> Names
forall (m :: * -> *). Branch0 m -> Names
Branch.toNames (Branch0 IO -> Names)
-> (Branch IO -> Branch0 IO) -> Branch IO -> Names
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Branch IO -> Branch0 IO
forall (m :: * -> *). Branch m -> Branch0 m
Branch.head (Branch IO -> Names) -> Cli (Branch IO) -> Cli Names
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ProjectBranch -> Cli (Branch IO)
Cli.getProjectBranchRoot ProjectBranch
pb