{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}

module Unison.CommandLine.OutputMessages where

import Control.Lens hiding (at)
import Control.Monad.State.Strict qualified as State
import Data.ByteString.Lazy qualified as LazyByteString
import Data.Foldable qualified as Foldable
import Data.List (stripPrefix)
import Data.List qualified as List
import Data.List.Extra (notNull, nubOrd, nubOrdOn)
import Data.List.NonEmpty qualified as NEList
import Data.Map qualified as Map
import Data.Sequence qualified as Seq
import Data.Set qualified as Set
import Data.Set.NonEmpty (NESet)
import Data.Text qualified as Text
import Data.Text.Encoding qualified as Text
import Data.Text.Lazy qualified as TL
import Data.Time (UTCTime, getCurrentTime)
import Data.Tuple (swap)
import Data.Tuple.Extra (dupe)
import Data.Void (absurd)
import Debug.RecoverRTTI qualified as RTTI
import Network.HTTP.Types qualified as Http
import Servant.Client qualified as Servant
import System.Console.ANSI qualified as ANSI
import System.Console.Haskeline.Completion qualified as Completion
import System.Directory (canonicalizePath, getHomeDirectory)
import Text.Pretty.Simple (pShowNoColor, pStringNoColor)
import U.Codebase.Branch (NamespaceStats (..))
import U.Codebase.Branch.Diff (NameChanges (..))
import U.Codebase.HashTags (CausalHash (..))
import U.Codebase.Reference qualified as Reference
import U.Codebase.Sqlite.Project (Project (..))
import U.Codebase.Sqlite.ProjectBranch (ProjectBranch (..))
import U.Codebase.Sqlite.ProjectReflog qualified as ProjectReflog
import Unison.ABT qualified as ABT
import Unison.Auth.Types qualified as Auth
import Unison.Builtin.Decls qualified as DD
import Unison.Cli.MergeTypes (MergeSourceAndTarget (..))
import Unison.Cli.Pretty
import Unison.Cli.ServantClientUtils qualified as ServantClientUtils
import Unison.Codebase.Editor.DisplayObject (DisplayObject (..))
import Unison.Codebase.Editor.Input (BranchIdG (..))
import Unison.Codebase.Editor.Input qualified as Input
import Unison.Codebase.Editor.Output
  ( CreatedProjectBranchFrom (..),
    NumberedArgs,
    NumberedOutput (..),
    Output (..),
    ShareError (..),
    TestReportStats (CachedTests, NewlyComputed),
    TodoOutput,
    UndoFailureReason (CantUndoPastMerge, CantUndoPastStart),
    todoOutputIsEmpty,
  )
import Unison.Codebase.Editor.Output qualified as E
import Unison.Codebase.Editor.Output.BranchDiff qualified as OBD
import Unison.Codebase.Editor.Output.PushPull qualified as PushPull
import Unison.Codebase.Editor.SlurpResult qualified as SlurpResult
import Unison.Codebase.Editor.StructuredArgument (StructuredArgument)
import Unison.Codebase.Editor.StructuredArgument qualified as SA
import Unison.Codebase.IntegrityCheck (IntegrityResult (..), prettyPrintIntegrityErrors)
import Unison.Codebase.Patch qualified as Patch
import Unison.Codebase.Path qualified as Path
import Unison.Codebase.Runtime qualified as Runtime
import Unison.Codebase.ShortCausalHash (ShortCausalHash)
import Unison.Codebase.ShortCausalHash qualified as SCH
import Unison.Codebase.SqliteCodebase.Conversions qualified as Cv
import Unison.CommandLine.FZFResolvers qualified as FZFResolvers
import Unison.CommandLine.Helpers (bigproblem, note, tip)
import Unison.CommandLine.InputPattern (InputPattern)
import Unison.CommandLine.InputPatterns (makeExample')
import Unison.CommandLine.InputPatterns qualified as IP
import Unison.ConstructorReference (GConstructorReference (..))
import Unison.ConstructorType qualified as CT
import Unison.Core.Project (ProjectBranchName (UnsafeProjectBranchName))
import Unison.DataDeclaration qualified as DD
import Unison.Hash qualified as Hash
import Unison.Hash32 (Hash32)
import Unison.HashQualified qualified as HQ
import Unison.HashQualifiedPrime qualified as HQ'
import Unison.LabeledDependency as LD
import Unison.Merge.DeclCoherencyCheck (IncoherentDeclReason (..), IncoherentDeclReasons (..))
import Unison.Name (Name)
import Unison.Name qualified as Name
import Unison.NameSegment qualified as NameSegment
import Unison.Names (Names (..))
import Unison.Names qualified as Names
import Unison.NamesWithHistory qualified as Names
import Unison.Parser.Ann (Ann, startingLine)
import Unison.Prelude
import Unison.PrettyPrintEnv qualified as PPE
import Unison.PrettyPrintEnv.Util qualified as PPE
import Unison.PrettyPrintEnvDecl qualified as PPED
import Unison.PrettyTerminal
  ( clearCurrentLine,
    putPretty',
  )
import Unison.PrintError
  ( prettyParseError,
    prettyResolutionFailures,
    prettyVar,
    printNoteWithSource,
    renderCompilerBug,
  )
import Unison.Project (ProjectAndBranch (..))
import Unison.Reference (Reference)
import Unison.Reference qualified as Reference
import Unison.Referent (Referent)
import Unison.Referent qualified as Referent
import Unison.ReferentPrime qualified as Referent
import Unison.Result qualified as Result
import Unison.Server.Backend (ShallowListEntry (..), TypeEntry (..))
import Unison.Server.Backend qualified as Backend
import Unison.Server.SearchResultPrime qualified as SR'
import Unison.Share.Sync qualified as Share
import Unison.Share.Sync.Types (CodeserverTransportError (..))
import Unison.Sync.Types qualified as Share
import Unison.Syntax.DeclPrinter qualified as DeclPrinter
import Unison.Syntax.HashQualified qualified as HQ (toText, unsafeFromVar)
import Unison.Syntax.Name qualified as Name (toText)
import Unison.Syntax.NamePrinter
  ( prettyHashQualified,
    prettyHashQualified',
    prettyName,
    prettyNamedReference,
    prettyNamedReferent,
    prettyReference,
    prettyReferent,
    prettyShortHash,
  )
import Unison.Syntax.NameSegment qualified as NameSegment
import Unison.Syntax.TermPrinter qualified as TermPrinter
import Unison.Syntax.TypePrinter qualified as TypePrinter
import Unison.Term (Term)
import Unison.Term qualified as Term
import Unison.Type (Type)
import Unison.UnisonFile qualified as UF
import Unison.Util.Conflicted (Conflicted (..))
import Unison.Util.Defn (Defn (..))
import Unison.Util.Defns (Defns (..))
import Unison.Util.List qualified as List
import Unison.Util.Monoid (intercalateMap)
import Unison.Util.Monoid qualified as Monoid
import Unison.Util.Pretty qualified as P
import Unison.Util.Relation qualified as R
import Unison.Var (Var)
import Unison.Var qualified as Var
import Unison.WatchKind qualified as WK
import Witch (unsafeFrom)

reportBugURL :: Pretty
reportBugURL :: Pretty ColorText
reportBugURL = Pretty ColorText
"https://github.com/unisonweb/unison/issues/new"

type Pretty = P.Pretty P.ColorText

shortenDirectory :: FilePath -> IO FilePath
shortenDirectory :: String -> IO String
shortenDirectory String
dir = do
  String
home <- IO String
getHomeDirectory
  pure $ case String -> String -> Maybe String
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix String
home String
dir of
    Just String
d -> String
"~" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
d
    Maybe String
Nothing -> String
dir

renderFileName :: FilePath -> IO Pretty
renderFileName :: String -> IO (Pretty ColorText)
renderFileName String
dir = Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> (String -> Pretty ColorText) -> String -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
P.blue (Pretty ColorText -> Pretty ColorText)
-> (String -> Pretty ColorText) -> String -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (String -> Pretty ColorText) -> IO String -> IO (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO String
shortenDirectory String
dir

notifyNumbered :: NumberedOutput -> (Pretty, NumberedArgs)
notifyNumbered :: NumberedOutput -> (Pretty ColorText, NumberedArgs)
notifyNumbered = \case
  ShowDiffNamespace Either ShortCausalHash ProjectPath
oldPrefix Either ShortCausalHash ProjectPath
newPrefix PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diffOutput ->
    ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe ((ShortCausalHash -> AbsBranchId)
-> (ProjectPath -> AbsBranchId)
-> Either ShortCausalHash ProjectPath
-> AbsBranchId
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ShortCausalHash -> AbsBranchId
forall p. ShortCausalHash -> BranchIdG p
BranchAtSCH ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath Either ShortCausalHash ProjectPath
oldPrefix) ((ShortCausalHash -> AbsBranchId)
-> (ProjectPath -> AbsBranchId)
-> Either ShortCausalHash ProjectPath
-> AbsBranchId
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ShortCausalHash -> AbsBranchId
forall p. ShortCausalHash -> BranchIdG p
BranchAtSCH ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath Either ShortCausalHash ProjectPath
newPrefix) BranchDiffOutput Symbol Ann
diffOutput
  ShowDiffAfterDeleteDefinitions PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diff ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText
undoTip
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
Path.absoluteEmpty) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
Path.absoluteEmpty) BranchDiffOutput Symbol Ann
diff)
  ShowDiffAfterDeleteBranch Absolute
bAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diff ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText
undoTip
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) BranchDiffOutput Symbol Ann
diff)
  ShowDiffAfterModifyBranch Path'
b' Absolute
_ PrettyPrintEnv
_ (BranchDiffOutput Symbol Ann -> Bool
forall v a. BranchDiffOutput v a -> Bool
OBD.isEmpty -> Bool
True) ->
    (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Nothing changed in" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
b' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".", NumberedArgs
forall a. Monoid a => a
mempty)
  ShowDiffAfterModifyBranch Path'
b' Absolute
bAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diff ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Here's what changed in" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
b' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
":",
              Pretty ColorText
"",
              Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText
undoTip
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) BranchDiffOutput Symbol Ann
diff)
  ShowDiffAfterMerge Either ProjectPath (ProjectAndBranch Project ProjectBranch)
_ ProjectPath
_ PrettyPrintEnv
_ (BranchDiffOutput Symbol Ann -> Bool
forall v a. BranchDiffOutput v a -> Bool
OBD.isEmpty -> Bool
True) ->
    (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Nothing changed as a result of the merge.", NumberedArgs
forall a. Monoid a => a
mempty)
  ShowDiffAfterMerge Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest' ProjectPath
destAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diffOutput ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Here's what's changed in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Either ProjectPath (ProjectAndBranch Project ProjectBranch)
-> Pretty ColorText
prettyNamespaceKey Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"after the merge:",
              Pretty ColorText
"",
              Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"You can use "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.todo
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to see if this generated any work to do in this namespace"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.test
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to run the tests."
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Or you can use"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.undo
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or use a hash from "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.branchReflog
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" with "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.reset
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to reset to a previous state."
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) BranchDiffOutput Symbol Ann
diffOutput)
  ShowDiffAfterMergePropagate Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest' ProjectPath
destAbs Path'
patchPath' PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diffOutput ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"Here's what's changed in "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Either ProjectPath (ProjectAndBranch Project ProjectBranch)
-> Pretty ColorText
prettyNamespaceKey Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest'
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"after applying the patch at "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
patchPath' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
":"),
              Pretty ColorText
"",
              Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"You can use "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.todo [Path' -> Pretty ColorText
prettyPath' Path'
patchPath', Either ProjectPath (ProjectAndBranch Project ProjectBranch)
-> Pretty ColorText
prettyNamespaceKey Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest']
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to see if this generated any work to do in this namespace"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.test
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to run the tests."
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Or you can use"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.undo
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or use a hash from "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.branchReflog
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to undo the results of this merge."
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) BranchDiffOutput Symbol Ann
diffOutput)
  ShowDiffAfterMergePreview Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest' ProjectPath
destAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diffOutput ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Here's what would change in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Either ProjectPath (ProjectAndBranch Project ProjectBranch)
-> Pretty ColorText
prettyNamespaceKey Either ProjectPath (ProjectAndBranch Project ProjectBranch)
dest' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"after the merge:",
              Pretty ColorText
"",
              Pretty ColorText
p
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) (ProjectPath -> AbsBranchId
forall p. ProjectPath -> BranchIdG p
BranchAtProjectPath ProjectPath
destAbs) BranchDiffOutput Symbol Ann
diffOutput)
  ShowDiffAfterUndo PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diffOutput ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      (\Pretty ColorText
p -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
"Here are the changes I undid", Pretty ColorText
"", Pretty ColorText
p])
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
Path.absoluteEmpty) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
Path.absoluteEmpty) BranchDiffOutput Symbol Ann
diffOutput)
  ShowDiffAfterPull Path'
dest' Absolute
destAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diff ->
    if BranchDiffOutput Symbol Ann -> Bool
forall v a. BranchDiffOutput v a -> Bool
OBD.isEmpty BranchDiffOutput Symbol Ann
diff
      then (Pretty ColorText
"✅  Looks like " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
dest' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is up to date.", NumberedArgs
forall a. Monoid a => a
mempty)
      else
        (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
          ( \Pretty ColorText
p ->
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Here's what's changed in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
dest' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"after the pull:",
                  Pretty ColorText
"",
                  Pretty ColorText
p,
                  Pretty ColorText
"",
                  Pretty ColorText
undoTip
                ]
          )
          (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
destAbs) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
destAbs) BranchDiffOutput Symbol Ann
diff)
  -- todo: these numbers aren't going to work,
  --  since the content isn't necessarily here.
  -- Should we have a mode with no numbers? :P

  ShowDiffAfterCreateAuthor NameSegment
authorNS Path'
authorPath' Absolute
bAbs PrettyPrintEnv
ppe BranchDiffOutput Symbol Ann
diff ->
    (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText, NumberedArgs)
-> (Pretty ColorText, NumberedArgs)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
      ( \Pretty ColorText
p ->
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText
p,
              Pretty ColorText
"",
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"Add"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName (NameSegment -> Name
Name.fromSegment NameSegment
NameSegment.licenseSegment)
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"values for"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName (NameSegment -> Name
Name.fromSegment NameSegment
authorNS)
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"under"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
authorPath' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            ]
      )
      (ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput Symbol Ann
-> (Pretty ColorText, NumberedArgs)
forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
ShowNumbers PrettyPrintEnv
ppe (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) (Absolute -> AbsBranchId
forall {p}. p -> BranchIdG p
absPathToBranchId Absolute
bAbs) BranchDiffOutput Symbol Ann
diff)
  TestResults TestReportStats
stats PrettyPrintEnv
ppe Bool
_showSuccess Bool
_showFailures Map TermReferenceId [Text]
oksUnsorted Map TermReferenceId [Text]
failsUnsorted ->
    let oks :: [(HashQualified Name, [Text])]
oks = ((HashQualified Name, [Text]) -> Text)
-> [(HashQualified Name, [Text])] -> [(HashQualified Name, [Text])]
forall a. (a -> Text) -> [a] -> [a]
Name.sortByText (HashQualified Name -> Text
HQ.toText (HashQualified Name -> Text)
-> ((HashQualified Name, [Text]) -> HashQualified Name)
-> (HashQualified Name, [Text])
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name, [Text]) -> HashQualified Name
forall a b. (a, b) -> a
fst) [(TermReferenceId -> HashQualified Name
name TermReferenceId
r, [Text]
msgs) | (TermReferenceId
r, [Text]
msgs) <- Map TermReferenceId [Text] -> [(TermReferenceId, [Text])]
forall k a. Map k a -> [(k, a)]
Map.toList Map TermReferenceId [Text]
oksUnsorted]
        fails :: [(HashQualified Name, [Text])]
fails = ((HashQualified Name, [Text]) -> Text)
-> [(HashQualified Name, [Text])] -> [(HashQualified Name, [Text])]
forall a. (a -> Text) -> [a] -> [a]
Name.sortByText (HashQualified Name -> Text
HQ.toText (HashQualified Name -> Text)
-> ((HashQualified Name, [Text]) -> HashQualified Name)
-> (HashQualified Name, [Text])
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name, [Text]) -> HashQualified Name
forall a b. (a, b) -> a
fst) [(TermReferenceId -> HashQualified Name
name TermReferenceId
r, [Text]
msgs) | (TermReferenceId
r, [Text]
msgs) <- Map TermReferenceId [Text] -> [(TermReferenceId, [Text])]
forall k a. Map k a -> [(k, a)]
Map.toList Map TermReferenceId [Text]
failsUnsorted]
        name :: TermReferenceId -> HashQualified Name
name TermReferenceId
r = PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName PrettyPrintEnv
ppe (TermReferenceId -> Referent
Referent.fromTermReferenceId TermReferenceId
r)
     in ( case TestReportStats
stats of
            CachedTests Int
0 Int
_ -> Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"No tests to run."
            CachedTests Int
n Int
n' | Int
n Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
n' -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
cache, Pretty ColorText
"", Bool
-> [(HashQualified Name, [Text])]
-> [(HashQualified Name, [Text])]
-> Pretty ColorText
displayTestResults Bool
True [(HashQualified Name, [Text])]
oks [(HashQualified Name, [Text])]
fails]
            CachedTests Int
_n Int
m ->
              if Int
m Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
                then Pretty ColorText
"✅  "
                else
                  Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
"", Pretty ColorText
cache, Pretty ColorText
"", Bool
-> [(HashQualified Name, [Text])]
-> [(HashQualified Name, [Text])]
-> Pretty ColorText
displayTestResults Bool
False [(HashQualified Name, [Text])]
oks [(HashQualified Name, [Text])]
fails, Pretty ColorText
"", Pretty ColorText
"✅  "]
            TestReportStats
NewlyComputed ->
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ Pretty ColorText
"  " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"New test results:",
                  Pretty ColorText
"",
                  Bool
-> [(HashQualified Name, [Text])]
-> [(HashQualified Name, [Text])]
-> Pretty ColorText
displayTestResults Bool
True [(HashQualified Name, [Text])]
oks [(HashQualified Name, [Text])]
fails
                ],
          ((HashQualified Name, [Text]) -> StructuredArgument)
-> [(HashQualified Name, [Text])] -> NumberedArgs
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (HashQualified Name -> StructuredArgument
SA.HashQualified (HashQualified Name -> StructuredArgument)
-> ((HashQualified Name, [Text]) -> HashQualified Name)
-> (HashQualified Name, [Text])
-> StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name, [Text]) -> HashQualified Name
forall a b. (a, b) -> a
fst) ([(HashQualified Name, [Text])] -> NumberedArgs)
-> [(HashQualified Name, [Text])] -> NumberedArgs
forall a b. (a -> b) -> a -> b
$ [(HashQualified Name, [Text])]
oks [(HashQualified Name, [Text])]
-> [(HashQualified Name, [Text])] -> [(HashQualified Name, [Text])]
forall a. Semigroup a => a -> a -> a
<> [(HashQualified Name, [Text])]
fails
        )
    where
      cache :: Pretty ColorText
cache = Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Cached test results " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"(`help testcache` to learn more)"
  Output'Todo TodoOutput
todoOutput -> Numbered (Pretty ColorText) -> (Pretty ColorText, NumberedArgs)
forall a. Numbered a -> (a, NumberedArgs)
runNumbered (TodoOutput -> Numbered (Pretty ColorText)
handleTodoOutput TodoOutput
todoOutput)
  CantDeleteDefinitions PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments ->
    ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I didn't delete the following definitions because they are still in use:",
            Pretty ColorText
"",
            PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency)
-> Pretty ColorText
endangeredDependentsTable PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments
          ],
      PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency) -> NumberedArgs
numberedArgsForEndangerments PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments
    )
  CantDeleteNamespace PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments ->
    ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I didn't delete the namespace because the following definitions are still in use.",
            Pretty ColorText
"",
            PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency)
-> Pretty ColorText
endangeredDependentsTable PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments,
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"If you want to proceed anyways and leave those definitions without names, use " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.patternName InputPattern
IP.deleteNamespaceForce)
          ],
      PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency) -> NumberedArgs
numberedArgsForEndangerments PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments
    )
  History Maybe Int
_cap Int
schLength [(CausalHash, Diff)]
history HistoryTail
tail ->
    let (Pretty ColorText
tailMsg, [CausalHash]
tailHashes) = Int -> (Pretty ColorText, [CausalHash])
handleTail ([(CausalHash, Diff)] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(CausalHash, Diff)]
history Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
        msg :: Pretty
        msg :: Pretty ColorText
msg =
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
note (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The most recent namespace hash is immediately below this message.",
              Pretty ColorText
"",
              Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n" [Int -> ShortCausalHash -> Diff -> Pretty ColorText
go Int
i (CausalHash -> ShortCausalHash
toSCH CausalHash
h) Diff
diff | (Int
i, (CausalHash
h, Diff
diff)) <- [Int] -> [(CausalHash, Diff)] -> [(Int, (CausalHash, Diff))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
1 ..] [(CausalHash, Diff)]
reversedHistory],
              Pretty ColorText
"",
              Pretty ColorText
tailMsg
            ]
        branchHashes :: [CausalHash]
        branchHashes :: [CausalHash]
branchHashes = ((CausalHash, Diff) -> CausalHash
forall a b. (a, b) -> a
fst ((CausalHash, Diff) -> CausalHash)
-> [(CausalHash, Diff)] -> [CausalHash]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(CausalHash, Diff)]
reversedHistory) [CausalHash] -> [CausalHash] -> [CausalHash]
forall a. Semigroup a => a -> a -> a
<> [CausalHash]
tailHashes
     in (Pretty ColorText
msg, CausalHash -> StructuredArgument
SA.Namespace (CausalHash -> StructuredArgument) -> [CausalHash] -> NumberedArgs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [CausalHash]
branchHashes)
    where
      toSCH :: CausalHash -> ShortCausalHash
      toSCH :: CausalHash -> ShortCausalHash
toSCH CausalHash
h = Int -> CausalHash -> ShortCausalHash
SCH.fromHash Int
schLength CausalHash
h
      reversedHistory :: [(CausalHash, Diff)]
reversedHistory = [(CausalHash, Diff)] -> [(CausalHash, Diff)]
forall a. [a] -> [a]
reverse [(CausalHash, Diff)]
history
      showNum :: Int -> Pretty
      showNum :: Int -> Pretty ColorText
showNum Int
n = Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
". "
      handleTail :: Int -> (Pretty, [CausalHash])
      handleTail :: Int -> (Pretty ColorText, [CausalHash])
handleTail Int
n = case HistoryTail
tail of
        E.EndOfLog CausalHash
h ->
          ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
              [ Pretty ColorText
"□ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
showNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH (CausalHash -> ShortCausalHash
toSCH CausalHash
h) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (start of history)"
              ],
            [CausalHash
h]
          )
        E.MergeTail CausalHash
h [CausalHash]
hs ->
          ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
              [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"This segment of history starts with a merge." Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
ex,
                Pretty ColorText
"",
                Pretty ColorText
"⊙ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
showNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH (CausalHash -> ShortCausalHash
toSCH CausalHash
h),
                Pretty ColorText
"⑃",
                [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([CausalHash]
hs [CausalHash]
-> ([CausalHash] -> [Pretty ColorText]) -> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& (Int -> CausalHash -> Pretty ColorText)
-> [CausalHash] -> [Pretty ColorText]
forall a b. (Int -> a -> b) -> [a] -> [b]
forall i (f :: * -> *) a b.
FunctorWithIndex i f =>
(i -> a -> b) -> f a -> f b
imap \Int
i CausalHash
h -> Int -> Pretty ColorText
showNum (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
i) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH (CausalHash -> ShortCausalHash
toSCH CausalHash
h))
              ],
            CausalHash
h CausalHash -> [CausalHash] -> [CausalHash]
forall a. a -> [a] -> [a]
: [CausalHash]
hs
          )
        E.PageEnd CausalHash
h Int
_n ->
          ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
              [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"There's more history before the versions shown here." Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
ex,
                Pretty ColorText
"",
                Pretty ColorText
dots,
                Pretty ColorText
"",
                Pretty ColorText
"⊙ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
showNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH (CausalHash -> ShortCausalHash
toSCH CausalHash
h),
                Pretty ColorText
""
              ],
            [CausalHash
h]
          )
      dots :: Pretty ColorText
dots = Pretty ColorText
"⠇"
      go :: Int -> ShortCausalHash -> Diff -> Pretty ColorText
go Int
i ShortCausalHash
sch Diff
diff =
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText
"⊙ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
showNum Int
i Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
sch,
            Pretty ColorText
"",
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Diff -> Pretty ColorText
prettyDiff Diff
diff
          ]
      ex :: Pretty ColorText
ex =
        Pretty ColorText
"Use"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.history [Pretty ColorText
"#som3n4m3space"]
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to view history starting from a given namespace hash."
  DeletedDespiteDependents PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments ->
    ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Of the things I deleted, the following are still used in the following definitions. They now contain un-named references.",
            Pretty ColorText
"",
            PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency)
-> Pretty ColorText
endangeredDependentsTable PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments
          ],
      PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency) -> NumberedArgs
numberedArgsForEndangerments PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
endangerments
    )
  ListProjects [Project]
projects ->
    ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList ((Project -> Pretty ColorText) -> [Project] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map (ProjectName -> Pretty ColorText
prettyProjectName (ProjectName -> Pretty ColorText)
-> (Project -> ProjectName) -> Project -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting ProjectName Project ProjectName -> Project -> ProjectName
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting ProjectName Project ProjectName
#name) [Project]
projects),
      (Project -> StructuredArgument) -> [Project] -> NumberedArgs
forall a b. (a -> b) -> [a] -> [b]
map (ProjectName -> StructuredArgument
SA.Project (ProjectName -> StructuredArgument)
-> (Project -> ProjectName) -> Project -> StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting ProjectName Project ProjectName -> Project -> ProjectName
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting ProjectName Project ProjectName
#name) [Project]
projects
    )
  ListBranches ProjectName
projectName [(ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])]
branches ->
    ( [Pretty ColorText] -> [[Pretty ColorText]] -> Pretty ColorText
P.columnNHeader
        [Pretty ColorText
"", Pretty ColorText
"Branch", Pretty ColorText
"Remote branch"]
        ( do
            (Int
i, (ProjectBranchName
branchName, [(URI, ProjectName, ProjectBranchName)]
remoteBranches0)) <- [Int]
-> [(ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])]
-> [(Int,
     (ProjectBranchName, [(URI, ProjectName, ProjectBranchName)]))]
forall a b. [a] -> [b] -> [(a, b)]
zip [(Int
1 :: Int) ..] [(ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])]
branches
            case [(URI, ProjectName, ProjectBranchName)]
-> Maybe
     ((URI, ProjectName, ProjectBranchName),
      [(URI, ProjectName, ProjectBranchName)])
forall s a. Cons s s a a => s -> Maybe (a, s)
uncons [(URI, ProjectName, ProjectBranchName)]
remoteBranches0 of
              Maybe
  ((URI, ProjectName, ProjectBranchName),
   [(URI, ProjectName, ProjectBranchName)])
Nothing -> [Pretty ColorText] -> [[Pretty ColorText]]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Pretty ColorText -> Pretty ColorText
P.hiBlack (Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
i Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."), ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branchName, Pretty ColorText
""]
              Just ((URI, ProjectName, ProjectBranchName)
firstRemoteBranch, [(URI, ProjectName, ProjectBranchName)]
remoteBranches) ->
                [ Pretty ColorText -> Pretty ColorText
P.hiBlack (Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
i Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
                  ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branchName,
                  (URI, ProjectName, ProjectBranchName) -> Pretty ColorText
prettyRemoteBranchInfo (URI, ProjectName, ProjectBranchName)
firstRemoteBranch
                ]
                  [Pretty ColorText] -> [[Pretty ColorText]] -> [[Pretty ColorText]]
forall a. a -> [a] -> [a]
: ((URI, ProjectName, ProjectBranchName) -> [Pretty ColorText])
-> [(URI, ProjectName, ProjectBranchName)] -> [[Pretty ColorText]]
forall a b. (a -> b) -> [a] -> [b]
map (\(URI, ProjectName, ProjectBranchName)
branch -> [Pretty ColorText
"", Pretty ColorText
"", (URI, ProjectName, ProjectBranchName) -> Pretty ColorText
prettyRemoteBranchInfo (URI, ProjectName, ProjectBranchName)
branch]) [(URI, ProjectName, ProjectBranchName)]
remoteBranches
        ),
      ((ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
 -> StructuredArgument)
-> [(ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])]
-> NumberedArgs
forall a b. (a -> b) -> [a] -> [b]
map
        (ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
SA.ProjectBranch (ProjectAndBranch (Maybe ProjectName) ProjectBranchName
 -> StructuredArgument)
-> ((ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
    -> ProjectAndBranch (Maybe ProjectName) ProjectBranchName)
-> (ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
-> StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe ProjectName
-> ProjectBranchName
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch (ProjectName -> Maybe ProjectName
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProjectName
projectName) (ProjectBranchName
 -> ProjectAndBranch (Maybe ProjectName) ProjectBranchName)
-> ((ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
    -> ProjectBranchName)
-> (ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])
-> ProjectBranchName
forall a b. (a, b) -> a
fst)
        [(ProjectBranchName, [(URI, ProjectName, ProjectBranchName)])]
branches
    )
  AmbiguousSwitch ProjectName
project (ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch) ->
    ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Pretty ColorText
"I'm not sure if you wanted to switch to the branch"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or the project"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Could you be more specific?"
        )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList
          [ ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (the branch " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" in the current project)",
            ProjectName -> Pretty ColorText
prettyProjectNameSlash ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (the project " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
", with the branch left unspecified)"
          ]
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( Pretty ColorText
"use "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
switch [Pretty ColorText
"1"]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
switch [Pretty ColorText
"2"]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to pick one of these."
          ),
      [ ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
SA.ProjectBranch (ProjectAndBranch (Maybe ProjectName) ProjectBranchName
 -> StructuredArgument)
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
forall a b. (a -> b) -> a -> b
$ Maybe ProjectName
-> ProjectBranchName
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch Maybe ProjectName
forall a. Maybe a
Nothing ProjectBranchName
branch,
        ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
SA.ProjectBranch (ProjectAndBranch (Maybe ProjectName) ProjectBranchName
 -> StructuredArgument)
-> (ProjectBranchName
    -> ProjectAndBranch (Maybe ProjectName) ProjectBranchName)
-> ProjectBranchName
-> StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe ProjectName
-> ProjectBranchName
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch (ProjectName -> Maybe ProjectName
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProjectName
project) (ProjectBranchName -> StructuredArgument)
-> ProjectBranchName -> StructuredArgument
forall a b. (a -> b) -> a -> b
$
          Text -> ProjectBranchName
UnsafeProjectBranchName Text
"main"
      ]
    )
    where
      switch :: [Pretty ColorText] -> Pretty ColorText
switch = InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.projectSwitch
  AmbiguousReset AmbiguousReset'Argument
sourceOfAmbiguity (ProjectAndBranch Project
_pn0 ProjectBranch
_bn0, Path
path) (ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch) ->
    ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Pretty ColorText
openingLine
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
orTheNamespace
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
relPath0
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"in the current branch."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Could you be more specific?"
        )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList
          [ ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (the branch " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" in the current project)",
            Pretty ColorText
relPath0 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (the relative path " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
relPath0 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" in the current branch)"
          ]
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( Pretty ColorText
"use "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
reset ([Pretty ColorText] -> [Pretty ColorText]
resetArgs [Pretty ColorText
"1"])
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
reset ([Pretty ColorText] -> [Pretty ColorText]
resetArgs [Pretty ColorText
"2"])
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to pick one of these."
          ),
      [ ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
SA.ProjectBranch (ProjectAndBranch (Maybe ProjectName) ProjectBranchName
 -> StructuredArgument)
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
-> StructuredArgument
forall a b. (a -> b) -> a -> b
$ Maybe ProjectName
-> ProjectBranchName
-> ProjectAndBranch (Maybe ProjectName) ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch Maybe ProjectName
forall a. Maybe a
Nothing ProjectBranchName
branch,
        Absolute -> StructuredArgument
SA.AbsolutePath Absolute
absPath0
      ]
    )
    where
      openingLine :: Pretty ColorText
openingLine = case AmbiguousReset'Argument
sourceOfAmbiguity of
        AmbiguousReset'Argument
E.AmbiguousReset'Hash -> Pretty ColorText
"I'm not sure if you wanted to reset to the branch"
        AmbiguousReset'Argument
E.AmbiguousReset'Target -> Pretty ColorText
"I'm not sure if you wanted to reset the branch"
      orTheNamespace :: Pretty ColorText
orTheNamespace = case AmbiguousReset'Argument
sourceOfAmbiguity of
        AmbiguousReset'Argument
E.AmbiguousReset'Hash -> Pretty ColorText
"or to the namespace"
        AmbiguousReset'Argument
E.AmbiguousReset'Target -> Pretty ColorText
"or the namespace"
      resetArgs :: [Pretty ColorText] -> [Pretty ColorText]
resetArgs = case AmbiguousReset'Argument
sourceOfAmbiguity of
        AmbiguousReset'Argument
E.AmbiguousReset'Hash -> \[Pretty ColorText]
xs -> [Pretty ColorText]
xs
        AmbiguousReset'Argument
E.AmbiguousReset'Target -> \[Pretty ColorText]
xs -> Pretty ColorText
"<some hash>" Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: [Pretty ColorText]
xs
      reset :: [Pretty ColorText] -> Pretty ColorText
reset = InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.reset
      relPath0 :: Pretty ColorText
relPath0 = Path -> Pretty ColorText
prettyPath Path
path
      absPath0 :: Absolute
absPath0 = Path -> Absolute
Path.Absolute Path
path
  ListNamespaceDependencies PrettyPrintEnv
_ppe ProjectPath
_path Map LabeledDependency (Set Name)
Empty -> (Pretty ColorText
"This namespace has no external dependencies.", NumberedArgs
forall a. Monoid a => a
mempty)
  ListNamespaceDependencies PrettyPrintEnv
ppe ProjectPath
path' Map LabeledDependency (Set Name)
externalDependencies ->
    ( Pretty ColorText
-> Pretty ColorText
-> [(Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
P.column2Header (Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"External dependency") (Pretty ColorText
"Dependents in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectPath -> Pretty ColorText
prettyProjectPath ProjectPath
path') ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        (Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
List.intersperse (Pretty ColorText, Pretty ColorText)
spacer (Map LabeledDependency (Set Name)
-> [(Pretty ColorText, Pretty ColorText)]
externalDepsTable Map LabeledDependency (Set Name)
externalDependencies),
      NumberedArgs
numberedArgs
    )
    where
      spacer :: (Pretty ColorText, Pretty ColorText)
spacer = (Pretty ColorText
"", Pretty ColorText
"")
      (Map Name Int
nameNumbers, NumberedArgs
numberedArgs) = Map LabeledDependency (Set Name) -> (Map Name Int, NumberedArgs)
numberedDependents Map LabeledDependency (Set Name)
externalDependencies
      getNameNumber :: Name -> Int
getNameNumber Name
name = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe (String -> Int
forall a. HasCallStack => String -> a
error String
"ListNamespaceDependencies: name is missing number") (Name -> Map Name Int -> Maybe Int
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Name
name Map Name Int
nameNumbers)
      numberedDependents :: Map LabeledDependency (Set Name) -> (Map Name Int, NumberedArgs)
      numberedDependents :: Map LabeledDependency (Set Name) -> (Map Name Int, NumberedArgs)
numberedDependents Map LabeledDependency (Set Name)
deps =
        Map LabeledDependency (Set Name)
deps
          Map LabeledDependency (Set Name)
-> (Map LabeledDependency (Set Name) -> [Set Name]) -> [Set Name]
forall a b. a -> (a -> b) -> b
& Map LabeledDependency (Set Name) -> [Set Name]
forall k a. Map k a -> [a]
Map.elems
          [Set Name]
-> ([Set Name] -> (Int, (Map Name Int, [Name])))
-> (Int, (Map Name Int, [Name]))
forall a b. a -> (a -> b) -> b
& ((Int, (Map Name Int, [Name]))
 -> Set Name -> (Int, (Map Name Int, [Name])))
-> (Int, (Map Name Int, [Name]))
-> [Set Name]
-> (Int, (Map Name Int, [Name]))
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
List.foldl'
            ( \(Int
nextNum, (Map Name Int
nameToNum, [Name]
args)) Set Name
names ->
                let unnumberedNames :: [Name]
unnumberedNames = Set Name -> [Name]
forall a. Set a -> [a]
Set.toList (Set Name -> [Name]) -> Set Name -> [Name]
forall a b. (a -> b) -> a -> b
$ Set Name -> Set Name -> Set Name
forall a. Ord a => Set a -> Set a -> Set a
Set.difference Set Name
names (Map Name Int -> Set Name
forall k a. Map k a -> Set k
Map.keysSet Map Name Int
nameToNum)
                    newNextNum :: Int
newNextNum = Int
nextNum Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [Name] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Name]
unnumberedNames
                 in ( Int
newNextNum,
                      ( Map Name Int
nameToNum Map Name Int -> Map Name Int -> Map Name Int
forall a. Semigroup a => a -> a -> a
<> ([(Name, Int)] -> Map Name Int
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([Name] -> [Int] -> [(Name, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Name]
unnumberedNames [Int
nextNum ..])),
                        [Name]
args [Name] -> [Name] -> [Name]
forall a. Semigroup a => a -> a -> a
<> [Name]
unnumberedNames
                      )
                    )
            )
            (Int
1, (Map Name Int
forall a. Monoid a => a
mempty, [Name]
forall a. Monoid a => a
mempty))
          (Int, (Map Name Int, [Name]))
-> ((Int, (Map Name Int, [Name])) -> (Map Name Int, [Name]))
-> (Map Name Int, [Name])
forall a b. a -> (a -> b) -> b
& (Int, (Map Name Int, [Name])) -> (Map Name Int, [Name])
forall a b. (a, b) -> b
snd
          (Map Name Int, [Name])
-> ((Map Name Int, [Name]) -> (Map Name Int, NumberedArgs))
-> (Map Name Int, NumberedArgs)
forall a b. a -> (a -> b) -> b
& ASetter
  (Map Name Int, [Name])
  (Map Name Int, NumberedArgs)
  Name
  StructuredArgument
-> (Name -> StructuredArgument)
-> (Map Name Int, [Name])
-> (Map Name Int, NumberedArgs)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (([Name] -> Identity NumberedArgs)
-> (Map Name Int, [Name]) -> Identity (Map Name Int, NumberedArgs)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
  (Map Name Int, [Name])
  (Map Name Int, NumberedArgs)
  [Name]
  NumberedArgs
_2 (([Name] -> Identity NumberedArgs)
 -> (Map Name Int, [Name]) -> Identity (Map Name Int, NumberedArgs))
-> ((Name -> Identity StructuredArgument)
    -> [Name] -> Identity NumberedArgs)
-> ASetter
     (Map Name Int, [Name])
     (Map Name Int, NumberedArgs)
     Name
     StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Identity StructuredArgument)
-> [Name] -> Identity NumberedArgs
Setter [Name] NumberedArgs Name StructuredArgument
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped) Name -> StructuredArgument
SA.Name
      externalDepsTable :: Map LabeledDependency (Set Name) -> [(P.Pretty P.ColorText, P.Pretty P.ColorText)]
      externalDepsTable :: Map LabeledDependency (Set Name)
-> [(Pretty ColorText, Pretty ColorText)]
externalDepsTable = (LabeledDependency
 -> Set Name -> [(Pretty ColorText, Pretty ColorText)])
-> Map LabeledDependency (Set Name)
-> [(Pretty ColorText, Pretty ColorText)]
forall m a.
Monoid m =>
(LabeledDependency -> a -> m) -> Map LabeledDependency a -> m
forall i (f :: * -> *) m a.
(FoldableWithIndex i f, Monoid m) =>
(i -> a -> m) -> f a -> m
ifoldMap ((LabeledDependency
  -> Set Name -> [(Pretty ColorText, Pretty ColorText)])
 -> Map LabeledDependency (Set Name)
 -> [(Pretty ColorText, Pretty ColorText)])
-> (LabeledDependency
    -> Set Name -> [(Pretty ColorText, Pretty ColorText)])
-> Map LabeledDependency (Set Name)
-> [(Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$ \LabeledDependency
ld Set Name
dependents ->
        [(LabeledDependency -> Pretty ColorText
prettyLD LabeledDependency
ld, Set Name -> Pretty ColorText
prettyDependents Set Name
dependents)]
      prettyLD :: LabeledDependency -> P.Pretty P.ColorText
      prettyLD :: LabeledDependency -> Pretty ColorText
prettyLD =
        Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor
          (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (LabeledDependency -> Pretty (SyntaxText' TypeReference))
-> LabeledDependency
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified
          (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> (LabeledDependency -> HashQualified Name)
-> LabeledDependency
-> Pretty (SyntaxText' TypeReference)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReference -> HashQualified Name)
-> (Referent -> HashQualified Name)
-> LabeledDependency
-> HashQualified Name
forall a.
(TypeReference -> a) -> (Referent -> a) -> LabeledDependency -> a
LD.fold
            (PrettyPrintEnv -> TypeReference -> HashQualified Name
PPE.typeName PrettyPrintEnv
ppe)
            (PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName PrettyPrintEnv
ppe)
      prettyDependents :: Set Name -> P.Pretty P.ColorText
      prettyDependents :: Set Name -> Pretty ColorText
prettyDependents Set Name
refs =
        Set Name
refs
          Set Name -> (Set Name -> [Name]) -> [Name]
forall a b. a -> (a -> b) -> b
& Set Name -> [Name]
forall a. Set a -> [a]
Set.toList
          [Name] -> ([Name] -> [Pretty ColorText]) -> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& (Name -> Pretty ColorText) -> [Name] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Name
name -> Int -> Pretty ColorText
formatNum (Name -> Int
getNameNumber Name
name) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name)
          [Pretty ColorText]
-> ([Pretty ColorText] -> Pretty ColorText) -> Pretty ColorText
forall a b. a -> (a -> b) -> b
& [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
  ShowProjectBranchReflog Maybe UTCTime
now MoreEntriesThanShown
moreToShow [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
entries -> Maybe UTCTime
-> MoreEntriesThanShown
-> [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
-> (Pretty ColorText, NumberedArgs)
displayProjectBranchReflogEntries Maybe UTCTime
now MoreEntriesThanShown
moreToShow [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
entries
  where
    absPathToBranchId :: p -> BranchIdG p
absPathToBranchId = p -> BranchIdG p
forall {p}. p -> BranchIdG p
BranchAtPath

undoTip :: P.Pretty P.ColorText
undoTip :: Pretty ColorText
undoTip =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
    Pretty ColorText
"You can use"
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.undo
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or use a hash from "
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.branchReflog
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to undo this change."

notifyUser :: FilePath -> Output -> IO Pretty
notifyUser :: String -> Output -> IO (Pretty ColorText)
notifyUser String
dir = \case
  SaveTermNameConflict Name
name ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
      (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout
      (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
      (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Cannot save the last run result into"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Name -> Text
Name.toText Name
name))
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"because that name conflicts with a name in the scratch file."
  Output
NoLastRunResult ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
      (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout
      (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
      (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"There is no previous evaluation to save."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Use"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked Pretty ColorText
"run"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to evaluate something before attempting"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to save it."
  Output
Success -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Done."
  PrintMessage Pretty ColorText
pretty -> do
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
pretty
  CouldntLoadBranch CausalHash
h ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I have reason to believe that"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> CausalHash -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown CausalHash
h
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"exists in the codebase, but there was a failure"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"when I tried to load it."
  NamespaceEmpty NonEmpty (Either ShortCausalHash ProjectPath)
p ->
    case NonEmpty (Either ShortCausalHash ProjectPath)
p of
      (Either ShortCausalHash ProjectPath
p0 NEList.:| []) ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
          (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout
          (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The namespace "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (ShortCausalHash -> Pretty ColorText)
-> (ProjectPath -> Pretty ColorText)
-> Either ShortCausalHash ProjectPath
-> Pretty ColorText
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ProjectPath -> Pretty ColorText
prettyProjectPath Either ShortCausalHash ProjectPath
p0
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is empty. Was there a typo?"
      NonEmpty (Either ShortCausalHash ProjectPath)
ps ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
          (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout
          (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The namespaces "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Pretty ColorText) -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.commas ((ShortCausalHash -> Pretty ColorText)
-> (ProjectPath -> Pretty ColorText)
-> Either ShortCausalHash ProjectPath
-> Pretty ColorText
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ProjectPath -> Pretty ColorText
prettyProjectPath (Either ShortCausalHash ProjectPath -> Pretty ColorText)
-> NonEmpty (Either ShortCausalHash ProjectPath)
-> NonEmpty (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (Either ShortCausalHash ProjectPath)
ps)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" are empty. Was there a typo?"
  LoadPullRequest ReadRemoteNamespace Void
baseNS ReadRemoteNamespace Void
headNS Path'
basePath Path'
headPath Path'
mergedPath Path'
squashedPath ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I checked out" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Void -> Text) -> ReadRemoteNamespace Void -> Pretty ColorText
forall a. (a -> Text) -> ReadRemoteNamespace a -> Pretty ColorText
prettyReadRemoteNamespaceWith Void -> Text
forall a. Void -> a
absurd ReadRemoteNamespace Void
baseNS Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
basePath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I checked out" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Void -> Text) -> ReadRemoteNamespace Void -> Pretty ColorText
forall a. (a -> Text) -> ReadRemoteNamespace a -> Pretty ColorText
prettyReadRemoteNamespaceWith Void -> Text
forall a. Void -> a
absurd ReadRemoteNamespace Void
headNS Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
headPath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The merged result is in" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
mergedPath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The (squashed) merged result is in" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path' -> Pretty ColorText
prettyPath' Path'
squashedPath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"Use"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                InputPattern
IP.diffNamespace
                [Path' -> Pretty ColorText
prettyPath' Path'
basePath, Path' -> Pretty ColorText
prettyPath' Path'
mergedPath]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                InputPattern
IP.diffNamespace
                [Path' -> Pretty ColorText
prettyPath' Path'
basePath, Path' -> Pretty ColorText
prettyPath' Path'
squashedPath]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to see what's been updated.",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"Use"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                InputPattern
IP.todo
                [ Path' -> Pretty ColorText
prettyPath' (Path' -> NameSegment -> Path'
forall s a. Snoc s s a a => s -> a -> s
snoc Path'
mergedPath NameSegment
NameSegment.defaultPatchSegment),
                  Path' -> Pretty ColorText
prettyPath' Path'
mergedPath
                ]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to see what work is remaining for the merge.",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"Use"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                InputPattern
IP.push
                [(Void -> Text) -> ReadRemoteNamespace Void -> Pretty ColorText
forall a. (a -> Text) -> ReadRemoteNamespace a -> Pretty ColorText
prettyReadRemoteNamespaceWith Void -> Text
forall a. Void -> a
absurd ReadRemoteNamespace Void
baseNS, Path' -> Pretty ColorText
prettyPath' Path'
mergedPath]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                InputPattern
IP.push
                [(Void -> Text) -> ReadRemoteNamespace Void -> Pretty ColorText
forall a. (a -> Text) -> ReadRemoteNamespace a -> Pretty ColorText
prettyReadRemoteNamespaceWith Void -> Text
forall a. Void -> a
absurd ReadRemoteNamespace Void
baseNS, Path' -> Pretty ColorText
prettyPath' Path'
squashedPath]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to push the changes."
        ]
  LoadedDefinitionsToSourceFile String
fp Int
numDefinitions ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"☝️" (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I added " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> forall a s. (Show a, IsString s) => a -> Pretty s
P.shown @Int Int
numDefinitions Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" definitions to the top of " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall a. IsString a => String -> a
fromString String
fp,
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"You can edit them there, then run"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.update
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to replace the definitions currently in this namespace."
          ]
  DisplayDefinitions Pretty ColorText
code -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
code
  OutputRewrittenFile String
dest [Symbol]
vs -> String -> [Symbol] -> IO (Pretty ColorText)
forall v. Var v => String -> [v] -> IO (Pretty ColorText)
displayOutputRewrittenFile String
dest [Symbol]
vs
  DisplayRendered Maybe String
outputLoc Pretty ColorText
pp ->
    Maybe String -> Pretty ColorText -> IO (Pretty ColorText)
displayRendered Maybe String
outputLoc Pretty ColorText
pp
  TestIncrementalOutputStart PrettyPrintEnv
ppe (Int
n, Int
total) TermReferenceId
r -> do
    Pretty ColorText -> IO ()
putPretty' (Pretty ColorText -> IO ()) -> Pretty ColorText -> IO ()
forall a b. (a -> b) -> a -> b
$
      Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown (Int
total Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n)
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" tests left to run, current test: "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName PrettyPrintEnv
ppe (Referent -> HashQualified Name) -> Referent -> HashQualified Name
forall a b. (a -> b) -> a -> b
$ TermReferenceId -> Referent
Referent.fromTermReferenceId TermReferenceId
r))
    pure Pretty ColorText
forall a. Monoid a => a
mempty
  TestIncrementalOutputEnd PrettyPrintEnv
_ppe (Int
_n, Int
_total) TermReferenceId
_r Bool
isOk -> do
    IO ()
clearCurrentLine
    if Bool
isOk
      then Pretty ColorText -> IO ()
putPretty' Pretty ColorText
"  ✅  "
      else Pretty ColorText -> IO ()
putPretty' Pretty ColorText
"  🚫  "
    pure Pretty ColorText
forall a. Monoid a => a
mempty
  TermMissingType TypeReference
ref ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The type signature for reference "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (TypeReference -> Text
Reference.toText TypeReference
ref))
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is missing from the codebase! This means something might be wrong "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" with the codebase, or the term was deleted just now "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" by someone else. Trying your command again might fix it."
      ]
  EvaluationFailure Pretty ColorText
err -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
err
  SearchTermsNotFound [HashQualified Name]
hqs | [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
hqs -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
  SearchTermsNotFound [HashQualified Name]
hqs ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout Pretty ColorText
"The following names were not found in the codebase. Check your spelling."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.indent Pretty (SyntaxText' TypeReference)
"  " ([Pretty (SyntaxText' TypeReference)]
-> Pretty (SyntaxText' TypeReference)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> [HashQualified Name] -> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
hqs)))
  SearchTermsNotFoundDetailed Bool
wasTerm [HashQualified Name]
hqMisses [HashQualified Name]
otherHits ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText
missMsg Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
hitMsg)
    where
      typeOrTermMsg :: Pretty ColorText
typeOrTermMsg =
        if Bool
wasTerm
          then Pretty ColorText
"I was expecting the following names to be terms, though I found types instead."
          else Pretty ColorText
"I was expecting the following names to be types, though I found terms instead."
      missMsg :: Pretty ColorText
missMsg = case [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
hqMisses of
        Bool
True -> Pretty ColorText
forall a. Monoid a => a
mempty
        Bool
False ->
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout Pretty ColorText
"The following names were not found in the codebase. Check your spelling."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.indent Pretty (SyntaxText' TypeReference)
"  " ([Pretty (SyntaxText' TypeReference)]
-> Pretty (SyntaxText' TypeReference)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> [HashQualified Name] -> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
hqMisses)))
      hitMsg :: Pretty ColorText
hitMsg = case [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
otherHits of
        Bool
True -> Pretty ColorText
forall a. Monoid a => a
mempty
        Bool
False ->
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout Pretty ColorText
typeOrTermMsg
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.indent Pretty (SyntaxText' TypeReference)
"  " ([Pretty (SyntaxText' TypeReference)]
-> Pretty (SyntaxText' TypeReference)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> [HashQualified Name] -> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
otherHits)))
  NameNotFound HQSplit'
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I don't know about that name."
  NamesNotFound [Name]
hqs ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout Pretty ColorText
"The following names were not found in the codebase. Check your spelling."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Pretty (SyntaxText' Any) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' Any) -> Pretty ColorText)
-> Pretty (SyntaxText' Any) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' Any)
-> Pretty (SyntaxText' Any) -> Pretty (SyntaxText' Any)
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.indent Pretty (SyntaxText' Any)
"  " ([Pretty (SyntaxText' Any)] -> Pretty (SyntaxText' Any)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((Name -> Pretty (SyntaxText' Any))
-> [Name] -> [Pretty (SyntaxText' Any)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Name -> Pretty (SyntaxText' Any)
forall s. IsString s => Name -> Pretty s
prettyName [Name]
hqs)))
  TermNotFound HQSplit'
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I don't know about that term."
  TypeNotFound HQSplit'
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I don't know about that type."
  MoveNothingFound Path'
p ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"There is no term, type, or namespace at " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
p Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
  TermAlreadyExists Split'
_ Set Referent
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"A term by that name already exists."
  TypeAlreadyExists Split'
_ Set TypeReference
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"A type by that name already exists."
  BranchEmpty WhichBranchEmpty
b ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (WhichBranchEmpty -> Pretty ColorText
prettyWhichBranchEmpty WhichBranchEmpty
b) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is an empty namespace."
  CantUndo UndoFailureReason
reason -> case UndoFailureReason
reason of
    UndoFailureReason
CantUndoPastStart -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Nothing more to undo."
    UndoFailureReason
CantUndoPastMerge -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Sorry, I can't undo a merge (not implemented yet)."
  NoMainFunction HashQualified Name
main PrettyPrintEnv
ppe [Type Symbol Ann]
ts ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"I looked for a function"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Text
HQ.toText HashQualified Name
main)
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"in the most recently typechecked file and codebase but couldn't find one. It has to have the type:",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (HashQualified Name -> Text
HQ.toText HashQualified Name
main) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" : " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> Type Symbol Ann -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Type v a -> Pretty ColorText
TypePrinter.pretty PrettyPrintEnv
ppe Type Symbol Ann
t | Type Symbol Ann
t <- [Type Symbol Ann]
ts]
        ]
  BadMainFunction Text
what HashQualified Name
main Type Symbol Ann
ty PrettyPrintEnv
ppe [Type Symbol Ann]
ts ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
"I found this function:",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (HashQualified Name -> Text
HQ.toText HashQualified Name
main) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" : " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> Type Symbol Ann -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Type v a -> Pretty ColorText
TypePrinter.pretty PrettyPrintEnv
ppe Type Symbol Ann
ty,
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
"but in order for me to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
what) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"it needs to be a subtype of:",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (HashQualified Name -> Text
HQ.toText HashQualified Name
main) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" : " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> Type Symbol Ann -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Type v a -> Pretty ColorText
TypePrinter.pretty PrettyPrintEnv
ppe Type Symbol Ann
t | Type Symbol Ann
t <- [Type Symbol Ann]
ts]
        ]
  Output
NoUnisonFile -> do
    String
dir' <- String -> IO String
canonicalizePath String
dir
    Pretty ColorText
fileName <- String -> IO (Pretty ColorText)
renderFileName String
dir'
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"There's nothing for me to add right now.",
          Pretty ColorText
"",
          [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 [(Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Hint:", Pretty ColorText -> Pretty ColorText
msg Pretty ColorText
fileName)]
        ]
    where
      msg :: Pretty ColorText -> Pretty ColorText
msg Pretty ColorText
dir =
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"I'm currently watching for definitions in .u files under the"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
dir
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"directory. Make sure you've updated something there before using the"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.add
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.update
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"commands, or use"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.load
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to load a file explicitly."
  InvalidSourceName String
name ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"The file "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (String -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown String
name)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" does not exist or is not a valid source file."
  InvalidStructuredFindReplace HashQualified Name
_sym ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ InputPattern -> Pretty ColorText
IP.helpFor InputPattern
IP.sfindReplace
  InvalidStructuredFind HashQualified Name
_sym ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ InputPattern -> Pretty ColorText
IP.helpFor InputPattern
IP.sfind
  SourceLoadFailed String
name ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"The file "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (String -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown String
name)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" could not be loaded."
  BadNamespace String
msg String
path ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Invalid namespace " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
path) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
", " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
msg
  BranchNotFound Path'
b ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The namespace " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (Path' -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Path'
b) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" doesn't exist."
  EmptyLooseCodePush Path'
b ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The namespace " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (Path' -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Path'
b) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is empty. There is nothing to push."
  EmptyProjectBranchPush ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is empty. There is nothing to push."
  CreatedNewBranch Absolute
path ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"☝️  The namespace " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Absolute -> Pretty ColorText
prettyAbsolute Absolute
path Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is empty."
  -- RenameOutput rootPath oldName newName r -> do
  --   nameChange "rename" "renamed" oldName newName r
  -- AliasOutput rootPath existingName newName r -> do
  --   nameChange "alias" "aliased" existingName newName r
  Output
DeletedEverything ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText
"Okay, I deleted everything except the history.",
        Pretty ColorText
"Use "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.undo
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to undo, or "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.mergeBuiltins
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to restore the absolute "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"basics to the current path."
      ]
  Output
DeleteEverythingConfirmation ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText
"Are you sure you want to clear away everything?",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
          ( Pretty ColorText
"You could use "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.projectCreate
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to switch to a new project instead,"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or delete the current branch with "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.deleteBranch
          )
      ]
  DeleteBranchConfirmation [(Path', (Names, [SearchResult' Symbol Ann]))]
_uniqueDeletions -> String -> IO (Pretty ColorText)
forall a. HasCallStack => String -> a
error String
"todo"
  -- let
  --   pretty (branchName, (ppe, results)) =
  --     header $ listOfDefinitions' ppe False results
  --     where
  --     header = plural uniqueDeletions id ((P.text branchName <> ":") `P.hang`)
  --
  -- in putPrettyLn . P.warnCallout
  --   $ P.wrap ("The"
  --   <> plural uniqueDeletions "namespace contains" "namespaces contain"
  --   <> "definitions that don't exist in any other branches:")
  --   <> P.border 2 (mconcat (fmap pretty uniqueDeletions))
  --   <> P.newline
  --   <> P.wrap "Please repeat the same command to confirm the deletion."
  Output
MoveRootBranchConfirmation ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText
"Moves which affect the root branch cannot be undone, are you sure?",
        Pretty ColorText
"Re-run the same command to proceed."
      ]
  MovedOverExistingBranch Path'
dest' ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"A branch existed at the destination:" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
dest' Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"so I over-wrote it.",
        Pretty ColorText
"",
        Pretty ColorText
undoTip
      ]
  ListOfDefinitions FindScope
fscope PrettyPrintEnv
ppe Bool
detailed [SearchResult' Symbol Ann]
results ->
    FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' Symbol Ann]
-> IO (Pretty ColorText)
forall v a.
Var v =>
FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> IO (Pretty ColorText)
listOfDefinitions FindScope
fscope PrettyPrintEnv
ppe Bool
detailed [SearchResult' Symbol Ann]
results
  GlobalFindBranchResults ProjectAndBranch ProjectName ProjectBranchName
projBranchName PrettyPrintEnv
ppe Bool
detailed [SearchResult' Symbol Ann]
results -> do
    Pretty ColorText
output <- FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' Symbol Ann]
-> IO (Pretty ColorText)
forall v a.
Var v =>
FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> IO (Pretty ColorText)
listOfDefinitions FindScope
Input.FindGlobal PrettyPrintEnv
ppe Bool
detailed [SearchResult' Symbol Ann]
results
    pure $
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Found results in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (forall target source. From source target => source -> target
into @Text ProjectAndBranch ProjectName ProjectBranchName
projBranchName),
          Pretty ColorText
"",
          Pretty ColorText
output
        ]
  ListNames Int
len [(TypeReference, [HashQualified Name])]
types [(Referent, [HashQualified Name])]
terms ->
    Int
-> [(TypeReference, [HashQualified Name])]
-> [(Referent, [HashQualified Name])]
-> IO (Pretty ColorText)
listOfNames Int
len [(TypeReference, [HashQualified Name])]
types [(Referent, [HashQualified Name])]
terms
  GlobalListNames ProjectAndBranch ProjectName ProjectBranchName
projectBranchName Int
len [(TypeReference, [HashQualified Name])]
types [(Referent, [HashQualified Name])]
terms -> do
    Pretty ColorText
output <- Int
-> [(TypeReference, [HashQualified Name])]
-> [(Referent, [HashQualified Name])]
-> IO (Pretty ColorText)
listOfNames Int
len [(TypeReference, [HashQualified Name])]
types [(Referent, [HashQualified Name])]
terms
    pure $
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Found results in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (forall target source. From source target => source -> target
into @Text ProjectAndBranch ProjectName ProjectBranchName
projectBranchName),
          Pretty ColorText
"",
          Pretty ColorText
output
        ]
  -- > names foo
  --   Terms:
  --     Hash: #asdflkjasdflkjasdf
  --     Names: .util.frobnicate foo blarg.mcgee
  --
  --   Term (with hash #asldfkjsdlfkjsdf): .util.frobnicate, foo, blarg.mcgee
  --   Types (with hash #hsdflkjsdfsldkfj): Optional, Maybe, foo
  ListShallow IO PrettyPrintEnv
buildPPE [ShallowListEntry Symbol Ann]
entries -> do
    let needPPE :: Bool
needPPE =
          [ShallowListEntry Symbol Ann]
entries
            [ShallowListEntry Symbol Ann]
-> ([ShallowListEntry Symbol Ann] -> Bool) -> Bool
forall a b. a -> (a -> b) -> b
& (ShallowListEntry Symbol Ann -> Bool)
-> [ShallowListEntry Symbol Ann] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any \case
              ShallowTermEntry {} -> Bool
True
              ShallowListEntry Symbol Ann
_ -> Bool
False
    PrettyPrintEnv
ppe <-
      if Bool
needPPE
        then IO PrettyPrintEnv
buildPPE
        else PrettyPrintEnv -> IO PrettyPrintEnv
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PrettyPrintEnv
PPE.empty
    -- todo: make a version of prettyNumberedResult to support 3-columns
    pure $
      if [ShallowListEntry Symbol Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ShallowListEntry Symbol Ann]
entries
        then ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
"nothing to show"
        else PrettyPrintEnv -> [ShallowListEntry Symbol Ann] -> Pretty ColorText
forall v a.
Var v =>
PrettyPrintEnv -> [ShallowListEntry v a] -> Pretty ColorText
numberedEntries PrettyPrintEnv
ppe [ShallowListEntry Symbol Ann]
entries
    where
      numberedEntries :: (Var v) => PPE.PrettyPrintEnv -> [ShallowListEntry v a] -> Pretty
      numberedEntries :: forall v a.
Var v =>
PrettyPrintEnv -> [ShallowListEntry v a] -> Pretty ColorText
numberedEntries PrettyPrintEnv
ppe [ShallowListEntry v a]
entries =
        ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s, Pretty s)] -> Pretty s
P.column3 ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
 -> Pretty ColorText)
-> ([(Integer, (Pretty ColorText, Pretty ColorText))]
    -> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [(Integer, (Pretty ColorText, Pretty ColorText))]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Integer, (Pretty ColorText, Pretty ColorText))
 -> (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> [(Integer, (Pretty ColorText, Pretty ColorText))]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Integer, (Pretty ColorText, Pretty ColorText))
-> (Pretty ColorText, Pretty ColorText, Pretty ColorText)
forall {a} {b} {c}.
Show a =>
(a, (b, c)) -> (Pretty ColorText, b, c)
f) ([(Integer
1 :: Integer) ..] [Integer]
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Integer, (Pretty ColorText, Pretty ColorText))]
forall a b. [a] -> [b] -> [(a, b)]
`zip` (ShallowListEntry v a -> (Pretty ColorText, Pretty ColorText))
-> [ShallowListEntry v a] -> [(Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (PrettyPrintEnv
-> ShallowListEntry v a -> (Pretty ColorText, Pretty ColorText)
forall v a.
Var v =>
PrettyPrintEnv
-> ShallowListEntry v a -> (Pretty ColorText, Pretty ColorText)
formatEntry PrettyPrintEnv
ppe) [ShallowListEntry v a]
entries)
        where
          f :: (a, (b, c)) -> (Pretty ColorText, b, c)
f (a
i, (b
p1, c
p2)) = (Pretty ColorText -> Pretty ColorText
P.hiBlack (Pretty ColorText -> Pretty ColorText)
-> (String -> Pretty ColorText) -> String -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (String -> Pretty ColorText) -> String -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ a -> String
forall a. Show a => a -> String
show a
i String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
".", b
p1, c
p2)
      formatEntry :: (Var v) => PPE.PrettyPrintEnv -> ShallowListEntry v a -> (Pretty, Pretty)
      formatEntry :: forall v a.
Var v =>
PrettyPrintEnv
-> ShallowListEntry v a -> (Pretty ColorText, Pretty ColorText)
formatEntry PrettyPrintEnv
ppe = \case
        ShallowTermEntry TermEntry v a
termEntry ->
          ( Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (TermEntry v a -> Pretty (SyntaxText' TypeReference))
-> TermEntry v a
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> (TermEntry v a -> HashQualified Name)
-> TermEntry v a
-> Pretty (SyntaxText' TypeReference)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TermEntry v a -> HashQualified Name
forall v a. TermEntry v a -> HashQualified Name
Backend.termEntryHQName (TermEntry v a -> Pretty ColorText)
-> TermEntry v a -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ TermEntry v a
termEntry,
            ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
"(" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
-> (Type v a -> Pretty ColorText)
-> Maybe (Type v a)
-> Pretty ColorText
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Pretty ColorText
"type missing" (PrettyPrintEnv -> Type v a -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Type v a -> Pretty ColorText
TypePrinter.pretty PrettyPrintEnv
ppe) (TermEntry v a -> Maybe (Type v a)
forall v a. TermEntry v a -> Maybe (Type v a)
Backend.termEntryType TermEntry v a
termEntry) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
")"
          )
        ShallowTypeEntry TypeEntry
typeEntry ->
          ( Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (TypeEntry -> Pretty (SyntaxText' TypeReference))
-> TypeEntry
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> (TypeEntry -> HashQualified Name)
-> TypeEntry
-> Pretty (SyntaxText' TypeReference)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeEntry -> HashQualified Name
Backend.typeEntryHQName (TypeEntry -> Pretty ColorText) -> TypeEntry -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ TypeEntry
typeEntry,
            TypeReference -> Pretty ColorText
forall {t} {h}. Reference' t h -> Pretty ColorText
isBuiltin (TypeEntry -> TypeReference
typeEntryReference TypeEntry
typeEntry)
          )
        ShallowBranchEntry NameSegment
ns CausalHash
_ (NamespaceStats {Int
numContainedTerms :: Int
$sel:numContainedTerms:NamespaceStats :: NamespaceStats -> Int
numContainedTerms, Int
numContainedTypes :: Int
$sel:numContainedTypes:NamespaceStats :: NamespaceStats -> Int
numContainedTypes}) ->
          ( (Pretty (SyntaxText' Any) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' Any) -> Pretty ColorText)
-> (NameSegment -> Pretty (SyntaxText' Any))
-> NameSegment
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Pretty (SyntaxText' Any)
forall s. IsString s => Name -> Pretty s
prettyName (Name -> Pretty (SyntaxText' Any))
-> (NameSegment -> Name) -> NameSegment -> Pretty (SyntaxText' Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSegment -> Name
Name.fromSegment) NameSegment
ns Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"/",
            case [Maybe (Pretty ColorText)] -> [Pretty ColorText]
forall a. [Maybe a] -> [a]
catMaybes [Pretty ColorText -> Int -> Maybe (Pretty ColorText)
formatCount Pretty ColorText
"term" Int
numContainedTerms, Pretty ColorText -> Int -> Maybe (Pretty ColorText)
formatCount Pretty ColorText
"type" Int
numContainedTypes] of
              [] -> Pretty ColorText
""
              [Pretty ColorText]
counts -> Pretty ColorText -> Pretty ColorText
P.hiBlack (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"(" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
-> (Pretty ColorText -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall (t :: * -> *) a b.
(Foldable t, Monoid a) =>
a -> (b -> a) -> t b -> a
intercalateMap Pretty ColorText
", " Pretty ColorText -> Pretty ColorText
forall a. a -> a
id [Pretty ColorText]
counts Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
")"
          )
        ShallowPatchEntry NameSegment
ns ->
          ( (Pretty (SyntaxText' Any) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' Any) -> Pretty ColorText)
-> (NameSegment -> Pretty (SyntaxText' Any))
-> NameSegment
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Pretty (SyntaxText' Any)
forall s. IsString s => Name -> Pretty s
prettyName (Name -> Pretty (SyntaxText' Any))
-> (NameSegment -> Name) -> NameSegment -> Pretty (SyntaxText' Any)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSegment -> Name
Name.fromSegment) NameSegment
ns,
            ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
"(patch)"
          )
      formatCount :: Pretty -> Int -> Maybe Pretty
      formatCount :: Pretty ColorText -> Int -> Maybe (Pretty ColorText)
formatCount Pretty ColorText
_thing Int
0 = Maybe (Pretty ColorText)
forall a. Maybe a
Nothing
      formatCount Pretty ColorText
thing Int
1 = Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just (Pretty ColorText -> Maybe (Pretty ColorText))
-> Pretty ColorText -> Maybe (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"1 " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
thing
      formatCount Pretty ColorText
thing Int
n = Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just (Pretty ColorText -> Maybe (Pretty ColorText))
-> Pretty ColorText -> Maybe (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
thing Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"s"
      isBuiltin :: Reference' t h -> Pretty ColorText
isBuiltin = \case
        Reference.Builtin {} -> ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
"(builtin type)"
        Reference.DerivedId {} -> ColorText -> Pretty ColorText
forall s. (IsString s, ListLike s Char) => s -> Pretty s
P.lit ColorText
"(type)"
  SlurpOutput Input
input PrettyPrintEnv
ppe SlurpResult
s ->
    let isPast :: Bool
isPast = case Input
input of
          Input.AddI {} -> Bool
True
          Input.UpdateI {} -> Bool
True
          Input.SaveExecuteResultI {} -> Bool
True
          Input
_ -> Bool
False
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Bool -> PrettyPrintEnv -> SlurpResult -> Pretty ColorText
SlurpResult.pretty Bool
isPast PrettyPrintEnv
ppe SlurpResult
s
  Output
FindNoLocalMatches ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"☝️" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I couldn't find matches in this namespace, searching in 'lib'..."
  Output
NoExactTypeMatches ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"☝️" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I couldn't find exact type matches, resorting to fuzzy matching..."
  TypeParseError String
src Err Symbol
e ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I couldn't parse the type you supplied:",
          Pretty ColorText
"",
          String -> Err Symbol -> Pretty ColorText
forall v. Var v => String -> Err v -> Pretty ColorText
prettyParseError String
src Err Symbol
e
        ]
  ParseResolutionFailures String
src [ResolutionFailure Ann]
es ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      String -> [ResolutionFailure Ann] -> Pretty ColorText
forall a.
(Annotated a, Ord a) =>
String -> [ResolutionFailure a] -> Pretty ColorText
prettyResolutionFailures String
src [ResolutionFailure Ann]
es
  TypeHasFreeVars Type Symbol Ann
typ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"The type uses these names, but I'm not sure what they are:",
          Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
", " ((Symbol -> Pretty ColorText) -> [Symbol] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (Symbol -> Text) -> Symbol -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> Text
forall v. Var v => v -> Text
Var.name) ([Symbol] -> [Pretty ColorText])
-> (Set Symbol -> [Symbol]) -> Set Symbol -> [Pretty ColorText]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set Symbol -> [Symbol]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set Symbol -> [Pretty ColorText])
-> Set Symbol -> [Pretty ColorText]
forall a b. (a -> b) -> a -> b
$ Type Symbol Ann -> Set Symbol
forall (f :: * -> *) v a. Term f v a -> Set v
ABT.freeVars Type Symbol Ann
typ)
        ]
  ParseErrors Text
src [Err Symbol]
es ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n" ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ String -> Err Symbol -> Pretty ColorText
forall v. Var v => String -> Err v -> Pretty ColorText
prettyParseError (Text -> String
Text.unpack Text
src) (Err Symbol -> Pretty ColorText)
-> [Err Symbol] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Err Symbol]
es
  TypeErrors Absolute
_curPath Text
src PrettyPrintEnv
ppenv [ErrorNote Symbol Ann]
notes -> do
    let showNote :: [ErrorNote Symbol Ann] -> Pretty ColorText
showNote =
          Pretty ColorText
-> (Note Symbol Ann -> Pretty ColorText)
-> [Note Symbol Ann]
-> Pretty ColorText
forall (t :: * -> *) a b.
(Foldable t, Monoid a) =>
a -> (b -> a) -> t b -> a
intercalateMap Pretty ColorText
"\n\n" (PrettyPrintEnv -> String -> Note Symbol Ann -> Pretty ColorText
forall v a.
(Var v, Annotated a, Show a, Ord a) =>
PrettyPrintEnv -> String -> Note v a -> Pretty ColorText
printNoteWithSource PrettyPrintEnv
ppenv (Text -> String
Text.unpack Text
src))
            ([Note Symbol Ann] -> Pretty ColorText)
-> ([ErrorNote Symbol Ann] -> [Note Symbol Ann])
-> [ErrorNote Symbol Ann]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ErrorNote Symbol Ann -> Note Symbol Ann)
-> [ErrorNote Symbol Ann] -> [Note Symbol Ann]
forall a b. (a -> b) -> [a] -> [b]
map ErrorNote Symbol Ann -> Note Symbol Ann
forall v loc. ErrorNote v loc -> Note v loc
Result.TypeError
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ [ErrorNote Symbol Ann] -> Pretty ColorText
showNote [ErrorNote Symbol Ann]
notes
  CompilerBugs Text
src PrettyPrintEnv
env [CompilerBug Symbol Ann]
bugs -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
-> (CompilerBug Symbol Ann -> Pretty ColorText)
-> [CompilerBug Symbol Ann]
-> Pretty ColorText
forall (t :: * -> *) a b.
(Foldable t, Monoid a) =>
a -> (b -> a) -> t b -> a
intercalateMap Pretty ColorText
"\n\n" CompilerBug Symbol Ann -> Pretty ColorText
bug [CompilerBug Symbol Ann]
bugs
    where
      bug :: CompilerBug Symbol Ann -> Pretty ColorText
bug = PrettyPrintEnv
-> String -> CompilerBug Symbol Ann -> Pretty ColorText
forall v loc.
(Var v, Annotated loc, Ord loc, Show loc) =>
PrettyPrintEnv -> String -> CompilerBug v loc -> Pretty ColorText
renderCompilerBug PrettyPrintEnv
env (Text -> String
Text.unpack Text
src)
  Evaluated Text
fileContents PrettyPrintEnv
ppe [(Symbol, Term Symbol ())]
bindings Map Symbol (Ann, String, Term Symbol (), Bool)
watches ->
    if Map Symbol (Ann, String, Term Symbol (), Bool) -> Bool
forall a. Map Symbol a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map Symbol (Ann, String, Term Symbol (), Bool)
watches
      then Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"\n"
      else -- todo: hashqualify binding names if necessary to distinguish them from
      --       defs in the codebase.  In some cases it's fine for bindings to
      --       shadow codebase names, but you don't want it to capture them in
      --       the decompiled output.

        let prettyBindings :: Pretty ColorText
prettyBindings =
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.bracket (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"The watch expression(s) reference these definitions:"
                  Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: Pretty ColorText
""
                  Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: [ Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ PrettyPrintEnv
-> HashQualified Name
-> Term Symbol ()
-> Pretty (SyntaxText' TypeReference)
forall v at ap a.
Var v =>
PrettyPrintEnv
-> HashQualified Name
-> Term2 v at ap v a
-> Pretty (SyntaxText' TypeReference)
TermPrinter.prettyBinding PrettyPrintEnv
ppe (Symbol -> HashQualified Name
forall v. Var v => v -> HashQualified Name
HQ.unsafeFromVar Symbol
v) Term Symbol ()
b
                      | (Symbol
v, Term Symbol ()
b) <- [(Symbol, Term Symbol ())]
bindings
                    ]
            prettyWatches :: Pretty ColorText
prettyWatches =
              Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep
                Pretty ColorText
"\n\n"
                [ Text
-> PrettyPrintEnv
-> Ann
-> String
-> Term Symbol ()
-> Bool
-> Pretty ColorText
forall v.
Var v =>
Text
-> PrettyPrintEnv
-> Ann
-> String
-> Term v ()
-> Bool
-> Pretty ColorText
watchPrinter Text
fileContents PrettyPrintEnv
ppe Ann
ann String
kind Term Symbol ()
evald Bool
isCacheHit
                  | (Ann
ann, String
kind, Term Symbol ()
evald, Bool
isCacheHit) <-
                      ((Ann, String, Term Symbol (), Bool) -> Ann)
-> [(Ann, String, Term Symbol (), Bool)]
-> [(Ann, String, Term Symbol (), Bool)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (\(Ann
a, String
_, Term Symbol ()
_, Bool
_) -> Ann
a) ([(Ann, String, Term Symbol (), Bool)]
 -> [(Ann, String, Term Symbol (), Bool)])
-> (Map Symbol (Ann, String, Term Symbol (), Bool)
    -> [(Ann, String, Term Symbol (), Bool)])
-> Map Symbol (Ann, String, Term Symbol (), Bool)
-> [(Ann, String, Term Symbol (), Bool)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Symbol (Ann, String, Term Symbol (), Bool)
-> [(Ann, String, Term Symbol (), Bool)]
forall a. Map Symbol a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Map Symbol (Ann, String, Term Symbol (), Bool)
 -> [(Ann, String, Term Symbol (), Bool)])
-> Map Symbol (Ann, String, Term Symbol (), Bool)
-> [(Ann, String, Term Symbol (), Bool)]
forall a b. (a -> b) -> a -> b
$ Map Symbol (Ann, String, Term Symbol (), Bool)
watches
                ]
         in -- todo: use P.nonempty
            Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
              if [(Symbol, Term Symbol ())] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Symbol, Term Symbol ())]
bindings
                then Pretty ColorText
prettyWatches
                else Pretty ColorText
prettyBindings Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"\n" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
prettyWatches
  RunResult PrettyPrintEnv
ppe Term Symbol ()
term -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PrettyPrintEnv -> Term Symbol () -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Term v a -> Pretty ColorText
TermPrinter.pretty PrettyPrintEnv
ppe Term Symbol ()
term)
  DisplayConflicts Relation Name Referent
termNamespace Relation Name TypeReference
typeNamespace ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
        Pretty ColorText
"\n\n"
        [ Pretty ColorText -> Set Name -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
Pretty ColorText -> f Name -> Pretty ColorText
showConflicts Pretty ColorText
"terms" Set Name
terms,
          Pretty ColorText -> Set Name -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
Pretty ColorText -> f Name -> Pretty ColorText
showConflicts Pretty ColorText
"types" Set Name
types
        ]
    where
      terms :: Set Name
terms = Relation Name Referent -> Set Name
forall a b. Relation a b -> Set a
R.dom Relation Name Referent
termNamespace
      types :: Set Name
types = Relation Name TypeReference -> Set Name
forall a b. Relation a b -> Set a
R.dom Relation Name TypeReference
typeNamespace
      showConflicts :: (Foldable f) => Pretty -> f Name -> Pretty
      showConflicts :: forall (f :: * -> *).
Foldable f =>
Pretty ColorText -> f Name -> Pretty ColorText
showConflicts Pretty ColorText
thingsName f Name
things =
        if (f Name -> Bool
forall a. f a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null f Name
things)
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else
            [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
              [ Pretty ColorText
"These " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
thingsName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" have conflicts: ",
                Pretty ColorText
"",
                [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [(Pretty ColorText
"  " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
x) | Name
x <- f Name -> [Name]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f Name
things]
              ]
  LoadingFile Text
sourceName -> do
    Pretty ColorText
fileName <- String -> IO (Pretty ColorText)
renderFileName (String -> IO (Pretty ColorText))
-> String -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Text -> String
Text.unpack Text
sourceName
    pure $ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Loading changes detected in " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText
fileName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  Typechecked Text
sourceName PrettyPrintEnv
ppe SlurpResult
slurpResult TypecheckedUnisonFile Symbol Ann
uf -> do
    let fileStatusMsg :: Pretty ColorText
fileStatusMsg = Bool -> PrettyPrintEnv -> SlurpResult -> Pretty ColorText
SlurpResult.pretty Bool
False PrettyPrintEnv
ppe SlurpResult
slurpResult
    let containsWatchExpressions :: Bool
containsWatchExpressions = [(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
-> Bool
forall a. [a] -> Bool
notNull ([(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
 -> Bool)
-> [(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
-> Bool
forall a b. (a -> b) -> a -> b
$ TypecheckedUnisonFile Symbol Ann
-> [(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
forall v a.
TypecheckedUnisonFile v a
-> [(String, [(v, a, Term v a, Type v a)])]
UF.watchComponents TypecheckedUnisonFile Symbol Ann
uf
    if TypecheckedUnisonFile Symbol Ann -> Bool
forall v a. TypecheckedUnisonFile v a -> Bool
UF.nonEmpty TypecheckedUnisonFile Symbol Ann
uf
      then do
        Pretty ColorText
fileName <- String -> IO (Pretty ColorText)
renderFileName (String -> IO (Pretty ColorText))
-> String -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Text -> String
Text.unpack Text
sourceName
        pure $
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty
            ( [ if Pretty ColorText
fileStatusMsg Pretty ColorText -> Pretty ColorText -> Bool
forall a. Eq a => a -> a -> Bool
== Pretty ColorText
forall a. Monoid a => a
mempty
                  then Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.okCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
fileName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" changed."
                  else
                    if SlurpResult -> Bool
SlurpResult.isAllDuplicates SlurpResult
slurpResult
                      then
                        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                          Pretty ColorText
"I found and"
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"typechecked"
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the definitions in "
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText
fileName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"This file "
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"has been previously added"
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to the codebase."
                      else
                        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesSpaced ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                              Pretty ColorText
"I found and"
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"typechecked"
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"these definitions in "
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText
fileName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"If you do an "
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.add
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or "
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.update Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"here's how your codebase would change:",
                            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Bool -> PrettyPrintEnv -> SlurpResult -> Pretty ColorText
SlurpResult.pretty Bool
False PrettyPrintEnv
ppe SlurpResult
slurpResult
                          ]
              ]
                [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. [a] -> [a] -> [a]
++ if Bool
containsWatchExpressions
                  then
                    [ Pretty ColorText
"",
                      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                        Pretty ColorText
"Now evaluating any watch expressions"
                          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"(lines starting with `>`)... "
                          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"Ctrl+C cancels.")
                    ]
                  else []
            )
      else
        if ([(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
 -> Bool)
-> [(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
-> Bool
forall a b. (a -> b) -> a -> b
$ TypecheckedUnisonFile Symbol Ann
-> [(String, [(Symbol, Ann, Term Symbol Ann, Type Symbol Ann)])]
forall v a.
TypecheckedUnisonFile v a
-> [(String, [(v, a, Term v a, Type v a)])]
UF.watchComponents TypecheckedUnisonFile Symbol Ann
uf)
          then
            Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"I loaded " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
sourceName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" and didn't find anything."
          else Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
  BustedBuiltins (Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList -> [TypeReference]
new) (Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList -> [TypeReference]
old) ->
    -- todo: this could be prettier!  Have a nice list like `find` gives, but
    -- that requires querying the codebase to determine term types.  Probably
    -- the only built-in types will be primitive types like `Int`, so no need
    -- to look up decl types.
    -- When we add builtin terms, they may depend on new derived types, so
    -- these derived types should be added to the branch too; but not
    -- necessarily ever be automatically deprecated.  (A library curator might
    -- deprecate them; more work needs to go into the idea of sharing deprecations and stuff.
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      case ([TypeReference]
new, [TypeReference]
old) of
        ([], []) -> String -> [Pretty ColorText]
forall a. HasCallStack => String -> a
error String
"BustedBuiltins busted, as there were no busted builtins."
        ([], [TypeReference]
old) ->
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"This codebase includes some builtins that are considered deprecated. Use the " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.updateBuiltins Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" command when you're ready to work on eliminating them from your codebase:")
            Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: Pretty ColorText
""
            Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: (TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (TypeReference -> Text) -> TypeReference -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Text
Reference.toText) [TypeReference]
old
        ([TypeReference]
new, []) ->
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"This version of Unison provides builtins that are not part of your codebase. Use " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.updateBuiltins Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to add them:")
            Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: Pretty ColorText
""
            Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: (TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (TypeReference -> Text) -> TypeReference -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Text
Reference.toText) [TypeReference]
new
        (new :: [TypeReference]
new@(TypeReference
_ : [TypeReference]
_), old :: [TypeReference]
old@(TypeReference
_ : [TypeReference]
_)) ->
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
              ( Pretty ColorText
"Sorry and/or good news!  This version of Unison supports a different set of builtins than this codebase uses.  You can use "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.updateBuiltins
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to add the ones you're missing and deprecate the ones I'm missing. 😉"
              ),
            Pretty ColorText
"You're missing:" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
`P.hang` [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (TypeReference -> Text) -> TypeReference -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Text
Reference.toText) [TypeReference]
new),
            Pretty ColorText
"I'm missing:" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
`P.hang` [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (TypeReference -> Text) -> TypeReference -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Text
Reference.toText) [TypeReference]
old)
          ]
  NoConfiguredRemoteMapping PushPull
pp Absolute
p -> do
    let (Text
localPathExample, Text
sharePathExample) =
          if Absolute -> Bool
Path.isRoot Absolute
p
            then (Text
"myproject", Text
"myuser.public.myproject")
            else (Path -> Text
Path.toText (Absolute -> Path
Path.unabsolute Absolute
p), Text
"myuser.public." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Path -> Text
Path.toText (Absolute -> Path
Path.unabsolute Absolute
p))
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"I don't know where to " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
-> Pretty ColorText -> PushPull -> Pretty ColorText
forall a. a -> a -> PushPull -> a
PushPull.fold Pretty ColorText
"push to." Pretty ColorText
"pull from." PushPull
pp,
          Pretty ColorText
"Add a `RemoteMapping` configuration to your .unisonConfig file. E.g.",
          Pretty ColorText
"",
          Pretty ColorText
"```",
          Pretty ColorText
"RemoteMapping {",
          Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text
"  " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
localPathExample Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" = \"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
sharePathExample Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\""),
          Pretty ColorText
"}",
          Pretty ColorText
"```",
          Pretty ColorText
"",
          Pretty ColorText
"Type `help " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
-> Pretty ColorText -> PushPull -> Pretty ColorText
forall a. a -> a -> PushPull -> a
PushPull.fold Pretty ColorText
"push" Pretty ColorText
"pull" PushPull
pp Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"` for more information."
        ]

  --  | ConfiguredRemoteMappingParseError PushPull Path' Text String
  ConfiguredRemoteMappingParseError PushPull
pp Absolute
p Text
url String
err ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"I couldn't understand the RemoteMapping that's set for"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Absolute -> Pretty ColorText
prettyAbsolute Absolute
p
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"in .unisonConfig",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The value I found was"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
P.blue (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text) Text
url
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"but I encountered the following error when trying to parse it:",
        Pretty ColorText
"",
        String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
err,
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"Type"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Pretty ColorText
"help " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
-> Pretty ColorText -> PushPull -> Pretty ColorText
forall a. a -> a -> PushPull -> a
PushPull.fold Pretty ColorText
"push" Pretty ColorText
"pull" PushPull
pp)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"for more information."
      ]
  NoBranchWithHash ShortCausalHash
_h ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"I don't know of a namespace with that hash."
  Output
NotImplemented -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"That's not implemented yet. Sorry! 😬"
  BranchAlreadyExists Path'
p ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"The namespace" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path' -> Pretty ColorText
prettyPath' Path'
p Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"already exists."
  LabeledReferenceNotFound HashQualified Name
hq ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference)
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"\129300" (Pretty ColorText -> Pretty ColorText)
-> (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference)
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference)
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> IO (Pretty ColorText))
-> Pretty (SyntaxText' TypeReference) -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty (SyntaxText' TypeReference)
"Sorry, I couldn't find anything named" Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
hq Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
"."
  LabeledReferenceAmbiguous Int
hashLen HashQualified Name
hq (Set LabeledDependency -> ([TypeReference], [Referent])
forall (t :: * -> *).
Foldable t =>
t LabeledDependency -> ([TypeReference], [Referent])
LD.partition -> ([TypeReference]
tps, [Referent]
tms)) ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"\129300" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"That name is ambiguous. It could refer to any of the following definitions:",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((Referent -> Pretty ColorText) -> [Referent] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map Referent -> Pretty ColorText
qualifyTerm [Referent]
tms [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. [a] -> [a] -> [a]
++ (TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map TypeReference -> Pretty ColorText
qualifyType [TypeReference]
tps))
      ]
    where
      qualifyTerm :: Referent -> Pretty
      qualifyTerm :: Referent -> Pretty ColorText
qualifyTerm =
        Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (Referent -> Pretty (SyntaxText' TypeReference))
-> Referent
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. case HashQualified Name
hq of
          HQ.NameOnly Name
n -> Int -> Name -> Referent -> Pretty (SyntaxText' TypeReference)
prettyNamedReferent Int
hashLen Name
n
          HQ.HashQualified Name
n ShortHash
_ -> Int -> Name -> Referent -> Pretty (SyntaxText' TypeReference)
prettyNamedReferent Int
hashLen Name
n
          HQ.HashOnly ShortHash
_ -> Int -> Referent -> Pretty (SyntaxText' TypeReference)
prettyReferent Int
hashLen
      qualifyType :: Reference -> Pretty
      qualifyType :: TypeReference -> Pretty ColorText
qualifyType =
        Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (TypeReference -> Pretty (SyntaxText' TypeReference))
-> TypeReference
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. case HashQualified Name
hq of
          HQ.NameOnly Name
n -> Int -> Name -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyNamedReference Int
hashLen Name
n
          HQ.HashQualified Name
n ShortHash
_ -> Int -> Name -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyNamedReference Int
hashLen Name
n
          HQ.HashOnly ShortHash
_ -> Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference Int
hashLen
  DeleteNameAmbiguous Int
hashLen HQSplit'
p Set Referent
tms Set TypeReference
tys ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"\129300" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I wasn't sure which of these you meant to delete:",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((Referent -> Pretty ColorText) -> [Referent] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map Referent -> Pretty ColorText
qualifyTerm (Set Referent -> [Referent]
forall a. Set a -> [a]
Set.toList Set Referent
tms) [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. [a] -> [a] -> [a]
++ (TypeReference -> Pretty ColorText)
-> [TypeReference] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map TypeReference -> Pretty ColorText
qualifyType (Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList Set TypeReference
tys))),
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"You may:",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, ListLike s Char, IsString s) =>
f (Pretty s) -> Pretty s
P.bulleted ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Delete one by an unambiguous name, given above.",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Delete them all by re-issuing the previous command."
          ]
      ]
    where
      name :: Name
      name :: Name
name = HashQualified Name -> Name
forall n. HashQualified n -> n
HQ'.toName (HashQualified Name -> Name) -> HashQualified Name -> Name
forall a b. (a -> b) -> a -> b
$ HQSplit' -> HashQualified Name
Path.nameFromHQSplit' HQSplit'
p
      qualifyTerm :: Referent -> Pretty
      qualifyTerm :: Referent -> Pretty ColorText
qualifyTerm = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (Referent -> Pretty (SyntaxText' TypeReference))
-> Referent
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Name -> Referent -> Pretty (SyntaxText' TypeReference)
prettyNamedReferent Int
hashLen Name
name
      qualifyType :: Reference -> Pretty
      qualifyType :: TypeReference -> Pretty ColorText
qualifyType = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (TypeReference -> Pretty (SyntaxText' TypeReference))
-> TypeReference
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Name -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyNamedReference Int
hashLen Name
name
  TermAmbiguous PrettyPrintEnv
_ HashQualified Name
_ Set Referent
tms | Set Referent -> Bool
forall a. Set a -> Bool
Set.null Set Referent
tms -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"I couldn't find any term by that name."
  TermAmbiguous PrettyPrintEnv
ppe HashQualified Name
_n Set Referent
tms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"🤔" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I wasn't sure which of these you meant:",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((Referent -> Pretty ColorText) -> [Referent] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map (HashQualified Name -> Pretty ColorText
phq (HashQualified Name -> Pretty ColorText)
-> (Referent -> HashQualified Name) -> Referent -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termNameOrHashOnly PrettyPrintEnv
ppe) (Set Referent -> [Referent]
forall a. Set a -> [a]
Set.toList Set Referent
tms))),
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip Pretty ColorText
"Try again, using one of the unambiguous choices above."
      ]
    where
      phq :: HashQualified Name -> Pretty ColorText
phq = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified
  HashAmbiguous ShortHash
h Set Referent
rs ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"\129300" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The hash"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortHash -> Pretty ColorText
forall s. IsString s => ShortHash -> Pretty s
prettyShortHash ShortHash
h
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is ambiguous."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Did you mean one of these hashes?",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (Referent -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown (Referent -> Pretty ColorText) -> [Referent] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set Referent -> [Referent]
forall a. Set a -> [a]
Set.toList Set Referent
rs),
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Try again with a few more hash characters to disambiguate."
      ]
  BranchHashAmbiguous ShortCausalHash
h Set ShortCausalHash
rs ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"\129300" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The namespace hash"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
h
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is ambiguous."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Did you mean one of these hashes?",
        Pretty ColorText
"",
        Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH (ShortCausalHash -> Pretty ColorText)
-> [ShortCausalHash] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set ShortCausalHash -> [ShortCausalHash]
forall a. Set a -> [a]
Set.toList Set ShortCausalHash
rs),
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Try again with a few more hash characters to disambiguate."
      ]
  BadName Text
n -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is not a kind of name I understand."
  TermNotFound' ShortHash
sh ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I could't find a term with hash "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (ShortHash -> Pretty ColorText
forall s. IsString s => ShortHash -> Pretty s
prettyShortHash ShortHash
sh)
  TypeNotFound' ShortHash
sh ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I could't find a type with hash "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (ShortHash -> Pretty ColorText
forall s. IsString s => ShortHash -> Pretty s
prettyShortHash ShortHash
sh)
  Output
AboutToPropagatePatch -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"Applying changes from patch..."
  Output
PatchNeedsToBeConflictFree ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I tried to auto-apply the patch, but couldn't because it contained"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"contradictory entries."
  PatchInvolvesExternalDependents PrettyPrintEnv
_ Set TypeReference
_ ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"That patch involves external dependents."
  ShowReflog [] -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The reflog is empty"
  ShowReflog [(Maybe UTCTime, ShortCausalHash, Text)]
entries -> do
    UTCTime
now <- IO UTCTime
getCurrentTime
    pure $
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
header,
          [Pretty ColorText] -> [[Pretty ColorText]] -> Pretty ColorText
P.numberedColumnNHeader [Pretty ColorText
"When", Pretty ColorText
"Root Hash", Pretty ColorText
"Action"] ([[Pretty ColorText]] -> Pretty ColorText)
-> [[Pretty ColorText]] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [(Maybe UTCTime, ShortCausalHash, Text)]
entries [(Maybe UTCTime, ShortCausalHash, Text)]
-> ((Maybe UTCTime, ShortCausalHash, Text) -> [Pretty ColorText])
-> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> UTCTime
-> (Maybe UTCTime, ShortCausalHash, Text) -> [Pretty ColorText]
renderEntry3Column UTCTime
now,
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Use " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.diffNamespace [Pretty ColorText
"1", Pretty ColorText
"7"] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to compare namespaces between two points in history."
        ]
    where
      header :: Pretty ColorText
header =
        case [(Maybe UTCTime, ShortCausalHash, Text)]
entries of
          ((Maybe UTCTime, ShortCausalHash, Text)
_head : (Maybe UTCTime
_, ShortCausalHash
prevSCH, Text
_) : [(Maybe UTCTime, ShortCausalHash, Text)]
_) ->
            [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
              [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                  Pretty ColorText
"Here is a log of the root namespace hashes,"
                    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"starting with the most recent,"
                    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"along with the command that got us there."
                    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Try:",
                Pretty ColorText
"",
                ( Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.wrapColumn2 ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    [ ( InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.forkLocal [Pretty ColorText
"2", Pretty ColorText
".old"],
                        Pretty ColorText
""
                      ),
                      ( InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.forkLocal [ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
prevSCH, Pretty ColorText
".old"],
                        Pretty ColorText
"to make an old namespace accessible again,"
                      ),
                      (Pretty ColorText
forall a. Monoid a => a
mempty, Pretty ColorText
forall a. Monoid a => a
mempty),
                      ( InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.reset [ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
prevSCH],
                        Pretty ColorText
"to reset the current namespace and its history to that of the specified"
                          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"namespace."
                      )
                    ]
                ),
                Pretty ColorText
""
              ]
          [(Maybe UTCTime, ShortCausalHash, Text)]
_ -> Pretty ColorText
forall a. Monoid a => a
mempty
      renderEntry3Column :: UTCTime -> (Maybe UTCTime, SCH.ShortCausalHash, Text) -> [Pretty]
      renderEntry3Column :: UTCTime
-> (Maybe UTCTime, ShortCausalHash, Text) -> [Pretty ColorText]
renderEntry3Column UTCTime
now (Maybe UTCTime
mayTime, ShortCausalHash
sch, Text
reason) =
        [Pretty ColorText
-> (UTCTime -> Pretty ColorText)
-> Maybe UTCTime
-> Pretty ColorText
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Pretty ColorText
"" (UTCTime -> UTCTime -> Pretty ColorText
prettyHumanReadableTime UTCTime
now) Maybe UTCTime
mayTime, Pretty ColorText -> Pretty ColorText
P.blue (ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
sch), Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Text
truncateReason Text
reason]
      truncateReason :: Text -> Text
      truncateReason :: Text -> Text
truncateReason Text
txt = case Int -> Text -> (Text, Text)
Text.splitAt Int
60 Text
txt of
        (Text
short, Text
"") -> Text
short
        (Text
short, Text
_) -> Text
short Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"..."
  Output
StartOfCurrentPathHistory ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"You're already at the very beginning! 🙂"
  PullAlreadyUpToDate ReadRemoteNamespace RemoteProjectBranch
ns ProjectAndBranch Project ProjectBranch
dest ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectAndBranch Project ProjectBranch
dest.project.name ProjectAndBranch Project ProjectBranch
dest.branch.name)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"was already up-to-date with"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ReadRemoteNamespace RemoteProjectBranch -> Pretty ColorText
prettyReadRemoteNamespace ReadRemoteNamespace RemoteProjectBranch
ns Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  PullSuccessful ReadRemoteNamespace RemoteProjectBranch
ns ProjectAndBranch Project ProjectBranch
dest ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.okCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"Successfully updated"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectAndBranch Project ProjectBranch
dest.project.name ProjectAndBranch Project ProjectBranch
dest.branch.name)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"from"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ReadRemoteNamespace RemoteProjectBranch -> Pretty ColorText
prettyReadRemoteNamespace ReadRemoteNamespace RemoteProjectBranch
ns Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  Output
AboutToMerge -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"Merging..."
  MergeOverEmpty ProjectAndBranch Project ProjectBranch
dest ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.okCallout (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"Successfully pulled into "
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group
            ( ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectAndBranch Project ProjectBranch
dest.project.name ProjectAndBranch Project ProjectBranch
dest.branch.name)
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
", which was empty."
            )
  MergeAlreadyUpToDate BranchRelativePath
src BranchRelativePath
dest ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        BranchRelativePath -> Pretty ColorText
prettyBranchRelativePath BranchRelativePath
dest
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"was already up-to-date with"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (BranchRelativePath -> Pretty ColorText
prettyBranchRelativePath BranchRelativePath
src Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  MergeAlreadyUpToDate2 MergeSourceAndTarget
aliceAndBob ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName MergeSourceAndTarget
aliceAndBob.alice
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"was already up-to-date with"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSource -> Pretty ColorText
prettyMergeSource MergeSourceAndTarget
aliceAndBob.bob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  MergeConflictedAliases MergeSourceOrTarget
aliceOrBob Defn (Name, Name) (Name, Name)
defn ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the merge:"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
          ( Pretty ColorText
"On the merge ancestor,"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ( let (Bool
isTerm, Name
name1, Name
name2) =
                         case Defn (Name, Name) (Name, Name)
defn of
                           TermDefn (Name
n1, Name
n2) -> (Bool
True, Name
n1, Name
n2)
                           TypeDefn (Name
n1, Name
n2) -> (Bool
False, Name
n1, Name
n2)
                    in Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name1
                         Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and"
                         Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name2
                         Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"were aliases for the same"
                         Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group ((if Bool
isTerm then Pretty ColorText
"term" else Pretty ColorText
"type") Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                 )
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"but on"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the names have different definitions currently. I'd need just a single new definition to use in their"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"dependents when I merge."
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Please fix up" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to resolve this. For example,")
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN
          Width
2
          ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, ListLike s Char, IsString s) =>
f (Pretty s) -> Pretty s
P.bulleted
              [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                  ( InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.update
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the definitions to be the same again, so that there's nothing for me to decide."
                  ),
                Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                  ( InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.moveAll
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.delete
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"all but one of the definitions; I'll use the remaining name when propagating updates."
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"(You can"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.moveAll
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"it back after the merge.)"
                  )
              ]
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"and then try merging again."
  MergeConflictInvolvingBuiltin Defn Name Name
defn ->
    let (Bool
isTerm, Name
name) =
          case Defn Name Name
defn of
            TermDefn Name
n -> (Bool
True, Name
n)
            TypeDefn Name
n -> (Bool
False, Name
n)
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the merge:",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
              ( Pretty ColorText
"There's a merge conflict on"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (if Bool
isTerm then Pretty ColorText
"term" else Pretty ColorText
"type")
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"but it's a builtin on one or both branches. I can't yet handle merge conflicts involving builtins."
              ),
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
              ( Pretty ColorText
"Please eliminate this conflict by updating one branch or the other, making"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the same on both branches, or making neither of them a builtin, and then try the merge again."
              )
          ]
  -- Note [DefnsInLibMessage] If you change this, also change the other similar one
  MergeDefnsInLib MergeSourceOrTarget
aliceOrBob ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the merge:",
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"On"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"there's a type or term at the top level of the `lib` namespace, where I only expect to find"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"subnamespaces representing library dependencies.",
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Please move or remove it and then try merging again."
      ]
  PreviewMergeAlreadyUpToDate ProjectPath
src ProjectPath
dest ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        ProjectPath -> Pretty ColorText
prettyProjectPath ProjectPath
dest
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is already up-to-date with"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectPath -> Pretty ColorText
prettyProjectPath ProjectPath
src)
  DumpNumberedArgs Int
schLength NumberedArgs
args ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ (StructuredArgument -> Pretty ColorText)
-> NumberedArgs -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (StructuredArgument -> Text)
-> StructuredArgument
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int -> StructuredArgument -> Text
IP.formatStructuredArgument (Int -> Maybe Int
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Int
schLength)) NumberedArgs
args
  HelpMessage InputPattern
pat -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ InputPattern -> Pretty ColorText
IP.showPatternHelp InputPattern
pat
  Output
NoOp -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string String
"I didn't make any changes."
  DumpBitBooster CausalHash
head Map CausalHash [CausalHash]
map ->
    let go :: [String] -> [CausalHash] -> [String]
go [String]
output [] = [String]
output
        go [String]
output (CausalHash
head : [CausalHash]
queue) = case CausalHash -> Map CausalHash [CausalHash] -> Maybe [CausalHash]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup CausalHash
head Map CausalHash [CausalHash]
map of
          Maybe [CausalHash]
Nothing -> [String] -> [CausalHash] -> [String]
go (CausalHash -> [CausalHash] -> String
forall {t :: * -> *}.
Foldable t =>
CausalHash -> t CausalHash -> String
renderLine CausalHash
head [] String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
output) [CausalHash]
queue
          Just [CausalHash]
tails -> [String] -> [CausalHash] -> [String]
go (CausalHash -> [CausalHash] -> String
forall {t :: * -> *}.
Foldable t =>
CausalHash -> t CausalHash -> String
renderLine CausalHash
head [CausalHash]
tails String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
output) ([CausalHash]
queue [CausalHash] -> [CausalHash] -> [CausalHash]
forall a. [a] -> [a] -> [a]
++ [CausalHash]
tails)
          where
            renderHash :: CausalHash -> String
renderHash = Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
10 (String -> String)
-> (CausalHash -> String) -> CausalHash -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> String) -> (CausalHash -> Text) -> CausalHash -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> Text
Hash.toBase32HexText (Hash -> Text) -> (CausalHash -> Hash) -> CausalHash -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CausalHash -> Hash
unCausalHash
            renderLine :: CausalHash -> t CausalHash -> String
renderLine CausalHash
head t CausalHash
tail =
              (CausalHash -> String
renderHash CausalHash
head)
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"|"
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> (CausalHash -> String) -> t CausalHash -> String
forall (t :: * -> *) a b.
(Foldable t, Monoid a) =>
a -> (b -> a) -> t b -> a
intercalateMap String
" " CausalHash -> String
renderHash t CausalHash
tail
                String -> String -> String
forall a. [a] -> [a] -> [a]
++ case Text -> Map Text String -> Maybe String
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (Hash -> Text
Hash.toBase32HexText (Hash -> Text) -> (CausalHash -> Hash) -> CausalHash -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CausalHash -> Hash
unCausalHash (CausalHash -> Text) -> CausalHash -> Text
forall a b. (a -> b) -> a -> b
$ CausalHash
head) Map Text String
tags of
                  Just String
t -> String
"|tag: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
t
                  Maybe String
Nothing -> String
""
            -- some specific hashes that we want to label in the output
            tags :: Map Text String
            tags :: Map Text String
tags =
              [(Text, String)] -> Map Text String
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Text, String)] -> Map Text String)
-> ([(String, Text)] -> [(Text, String)])
-> [(String, Text)]
-> Map Text String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((String, Text) -> (Text, String))
-> [(String, Text)] -> [(Text, String)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (String, Text) -> (Text, String)
forall a b. (a, b) -> (b, a)
swap ([(String, Text)] -> Map Text String)
-> [(String, Text)] -> Map Text String
forall a b. (a -> b) -> a -> b
$
                [ (String
"unisonbase 2019/8/6", Text
"54s9qjhaonotuo4sp6ujanq7brngk32f30qt5uj61jb461h9fcca6vv5levnoo498bavne4p65lut6k6a7rekaruruh9fsl19agu8j8"),
                  (String
"unisonbase 2019/8/5", Text
"focmbmg7ca7ht7opvjaqen58fobu3lijfa9adqp7a1l1rlkactd7okoimpfmd0ftfmlch8gucleh54t3rd1e7f13fgei86hnsr6dt1g"),
                  (String
"unisonbase 2019/7/31", Text
"jm2ltsg8hh2b3c3re7aru6e71oepkqlc3skr2v7bqm4h1qgl3srucnmjcl1nb8c9ltdv56dpsgpdur1jhpfs6n5h43kig5bs4vs50co"),
                  (String
"unisonbase 2019/7/25", Text
"an1kuqsa9ca8tqll92m20tvrmdfk0eksplgjbda13evdlngbcn5q72h8u6nb86ojr7cvnemjp70h8cq1n95osgid1koraq3uk377g7g"),
                  (String
"ucm m1b", Text
"o6qocrqcqht2djicb1gcmm5ct4nr45f8g10m86bidjt8meqablp0070qae2tvutnvk4m9l7o1bkakg49c74gduo9eati20ojf0bendo"),
                  (String
"ucm m1, m1a", Text
"auheev8io1fns2pdcnpf85edsddj27crpo9ajdujum78dsncvfdcdu5o7qt186bob417dgmbd26m8idod86080bfivng1edminu3hug")
                ]
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((String -> Pretty ColorText) -> [String] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Pretty ColorText
forall a. IsString a => String -> a
fromString ([String] -> [Pretty ColorText])
-> ([String] -> [String]) -> [String] -> [Pretty ColorText]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> [String]
forall a. [a] -> [a]
reverse ([String] -> [String])
-> ([String] -> [String]) -> [String] -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> [String]
forall a. Ord a => [a] -> [a]
nubOrd ([String] -> [Pretty ColorText]) -> [String] -> [Pretty ColorText]
forall a b. (a -> b) -> a -> b
$ [String] -> [CausalHash] -> [String]
go [] [CausalHash
head]),
              Pretty ColorText
"",
              Pretty ColorText
"Paste that output into http://bit-booster.com/graph.html"
            ]
  ListDependents PrettyPrintEnv
ppe Set LabeledDependency
lds [HashQualified Name]
types [HashQualified Name]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ PrettyPrintEnv
-> Text
-> Text
-> Set LabeledDependency
-> [HashQualified Name]
-> [HashQualified Name]
-> Pretty ColorText
listDependentsOrDependencies PrettyPrintEnv
ppe Text
"Dependents" Text
"dependents" Set LabeledDependency
lds [HashQualified Name]
types [HashQualified Name]
terms
  ListDependencies PrettyPrintEnv
ppe Set LabeledDependency
lds [HashQualified Name]
types [HashQualified Name]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ PrettyPrintEnv
-> Text
-> Text
-> Set LabeledDependency
-> [HashQualified Name]
-> [HashQualified Name]
-> Pretty ColorText
listDependentsOrDependencies PrettyPrintEnv
ppe Text
"Dependencies" Text
"dependencies" Set LabeledDependency
lds [HashQualified Name]
types [HashQualified Name]
terms
  ListStructuredFind [HashQualified Name]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Bool
-> Maybe (Pretty ColorText)
-> [HashQualified Name]
-> Pretty ColorText
listFind Bool
False Maybe (Pretty ColorText)
forall a. Maybe a
Nothing [HashQualified Name]
terms
  ListTextFind Bool
True [HashQualified Name]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Bool
-> Maybe (Pretty ColorText)
-> [HashQualified Name]
-> Pretty ColorText
listFind Bool
True Maybe (Pretty ColorText)
forall a. Maybe a
Nothing [HashQualified Name]
terms
  ListTextFind Bool
False [HashQualified Name]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Bool
-> Maybe (Pretty ColorText)
-> [HashQualified Name]
-> Pretty ColorText
listFind Bool
False (Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just Pretty ColorText
tip) [HashQualified Name]
terms
    where
      tip :: Pretty ColorText
tip = (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample (Bool -> InputPattern
IP.textfind Bool
True) [] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" will search `lib` as well.")
  DumpUnisonFileHashes Int
hqLength [(Name, TermReferenceId)]
datas [(Name, TermReferenceId)]
effects [(Name, TermReferenceId)]
terms ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty (SyntaxText' TypeReference)] -> Pretty ColorText)
-> [Pretty (SyntaxText' TypeReference)]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> ([Pretty (SyntaxText' TypeReference)]
    -> Pretty (SyntaxText' TypeReference))
-> [Pretty (SyntaxText' TypeReference)]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty (SyntaxText' TypeReference)]
-> Pretty (SyntaxText' TypeReference)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty (SyntaxText' TypeReference)] -> IO (Pretty ColorText))
-> [Pretty (SyntaxText' TypeReference)] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ( [(Name, TermReferenceId)]
effects [(Name, TermReferenceId)]
-> ((Name, TermReferenceId) -> Pretty (SyntaxText' TypeReference))
-> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, TermReferenceId
r) ->
          Pretty (SyntaxText' TypeReference)
"ability "
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (Int -> HashQualified Name -> HashQualified Name
forall n. Int -> HashQualified n -> HashQualified n
HQ'.take Int
hqLength (HashQualified Name -> HashQualified Name)
-> (TypeReference -> HashQualified Name)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> TypeReference -> HashQualified Name
forall n. n -> TypeReference -> HashQualified n
HQ'.fromNamedReference Name
n (TypeReference -> HashQualified Name)
-> TypeReference -> HashQualified Name
forall a b. (a -> b) -> a -> b
$ TermReferenceId -> TypeReference
forall h t. Id' h -> Reference' t h
Reference.DerivedId TermReferenceId
r)
      )
        [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
forall a. Semigroup a => a -> a -> a
<> ( [(Name, TermReferenceId)]
datas [(Name, TermReferenceId)]
-> ((Name, TermReferenceId) -> Pretty (SyntaxText' TypeReference))
-> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, TermReferenceId
r) ->
               Pretty (SyntaxText' TypeReference)
"type "
                 Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (Int -> HashQualified Name -> HashQualified Name
forall n. Int -> HashQualified n -> HashQualified n
HQ'.take Int
hqLength (HashQualified Name -> HashQualified Name)
-> (TypeReference -> HashQualified Name)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> TypeReference -> HashQualified Name
forall n. n -> TypeReference -> HashQualified n
HQ'.fromNamedReference Name
n (TypeReference -> HashQualified Name)
-> TypeReference -> HashQualified Name
forall a b. (a -> b) -> a -> b
$ TermReferenceId -> TypeReference
forall h t. Id' h -> Reference' t h
Reference.DerivedId TermReferenceId
r)
           )
        [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
forall a. Semigroup a => a -> a -> a
<> ( [(Name, TermReferenceId)]
terms [(Name, TermReferenceId)]
-> ((Name, TermReferenceId) -> Pretty (SyntaxText' TypeReference))
-> [Pretty (SyntaxText' TypeReference)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, TermReferenceId
r) ->
               HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (Int -> HashQualified Name -> HashQualified Name
forall n. Int -> HashQualified n -> HashQualified n
HQ'.take Int
hqLength (HashQualified Name -> HashQualified Name)
-> (TypeReference -> HashQualified Name)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> TypeReference -> HashQualified Name
forall n. n -> TypeReference -> HashQualified n
HQ'.fromNamedReference Name
n (TypeReference -> HashQualified Name)
-> TypeReference -> HashQualified Name
forall a b. (a -> b) -> a -> b
$ TermReferenceId -> TypeReference
forall h t. Id' h -> Reference' t h
Reference.DerivedId TermReferenceId
r)
           )
  GistCreated ReadRemoteNamespace Void
remoteNamespace ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Gist created. Pull via:",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (InputPattern -> Pretty ColorText
IP.patternName InputPattern
IP.pull Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Void -> Text) -> ReadRemoteNamespace Void -> Pretty ColorText
forall a. (a -> Text) -> ReadRemoteNamespace a -> Pretty ColorText
prettyReadRemoteNamespaceWith Void -> Text
forall a. Void -> a
absurd ReadRemoteNamespace Void
remoteNamespace)
        ]
  InitiateAuthFlow URI
authURI -> do
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"Please navigate to " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyURI URI
authURI Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to authorize UCM with the codebase server."
  UnknownCodeServer Text
codeServerName -> do
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"No host configured for code server " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.red (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
codeServerName) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".",
          Pretty ColorText
"You can configure code server hosts in your .unisonConfig file."
        ]
  CredentialFailureMsg CredentialFailure
err -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ case CredentialFailure
err of
    Auth.ReauthRequired CodeserverId
host ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Authentication for host " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.red (CodeserverId -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown CodeserverId
host) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is required.",
          Pretty ColorText
"Run "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.help [InputPattern -> Pretty ColorText
IP.patternName InputPattern
IP.authLogin]
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to learn how."
        ]
    Auth.CredentialParseFailure String
fp Text
txt ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to parse the credentials file at " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
prettyFilePath String
fp Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
", with error: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".",
          Pretty ColorText
"You can attempt to fix the issue, or may simply delete the credentials file and run " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.authLogin [] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
        ]
    Auth.InvalidDiscoveryDocument URI
uri Text
txt ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to parse the discover document from " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyURI URI
uri Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
", with error: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
        ]
    Auth.InvalidJWT Text
txt ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to validate JWT from authentication server: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt
        ]
    Auth.RefreshFailure Text
txt ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to refresh access token with authentication server: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt
        ]
    Auth.InvalidTokenResponse URI
uri Text
txt ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to parse token response from authentication server: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyURI URI
uri,
          Pretty ColorText
"The error was: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt
        ]
    Auth.InvalidHost CodeserverURI
host ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to parse a URI from the hostname: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> CodeserverURI -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown CodeserverURI
host Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".",
          Pretty ColorText
"Host names should NOT include a schema or path."
        ]
    Auth.FailedToFetchUserInfo URI
userInfoEndpoint Text
err ->
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText
"Failed to parse the response from user info endpoint: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown URI
userInfoEndpoint,
          Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
err,
          Pretty ColorText
"Please `auth.login` then try again, if this error persists please file a bug report and include the above error message."
        ]
  PrintVersion Text
ucmVersion -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
ucmVersion)
  ShareError ShareError
shareError -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShareError -> Pretty ColorText
prettyShareError ShareError
shareError)
  ViewOnShare (URI, ProjectName, ProjectBranchName)
shareRef ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"View it here: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (URI, ProjectName, ProjectBranchName) -> Pretty ColorText
prettyRemoteBranchInfo (URI, ProjectName, ProjectBranchName)
shareRef
  IntegrityCheck IntegrityResult
result -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ case IntegrityResult
result of
    IntegrityResult
NoIntegrityErrors -> Pretty ColorText
"🎉 No issues detected 🎉"
    IntegrityErrorDetected NESet IntegrityError
ns -> NESet IntegrityError -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f IntegrityError -> Pretty ColorText
prettyPrintIntegrityErrors NESet IntegrityError
ns
  DebugTerm Bool
verbose Either Text (Term Symbol Ann)
builtinOrTerm -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ case Either Text (Term Symbol Ann)
builtinOrTerm of
    Left Text
builtin -> Pretty ColorText
"Builtin term: ##" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
builtin
    Right Term Symbol Ann
trm ->
      if Bool
verbose
        then Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (String -> Text) -> String -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.toStrict (Text -> Text) -> (String -> Text) -> String -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pStringNoColor (String -> Pretty ColorText) -> String -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Term Symbol Ann -> String
forall a. a -> String
RTTI.anythingToString Term Symbol Ann
trm
        else Term Symbol Ann -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Term Symbol Ann
trm
  DebugDecl Either Text (Decl Symbol Ann)
typ Maybe ConstructorId
mayConId -> do
    let constructorMsg :: Pretty ColorText
constructorMsg = case Maybe ConstructorId
mayConId of
          Maybe ConstructorId
Nothing -> Pretty ColorText
""
          Just ConstructorId
conId -> Pretty ColorText
"Constructor #" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ConstructorId -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown ConstructorId
conId Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" of the following type:\n"
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
constructorMsg
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> case Either Text (Decl Symbol Ann)
typ of
          Left Text
builtinTxt -> Pretty ColorText
"Builtin type: ##" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
builtinTxt
          Right Decl Symbol Ann
decl -> (EffectDeclaration Symbol Ann -> Pretty ColorText)
-> (DataDeclaration Symbol Ann -> Pretty ColorText)
-> Decl Symbol Ann
-> Pretty ColorText
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (EffectDeclaration Symbol Ann -> Text)
-> EffectDeclaration Symbol Ann
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.toStrict (Text -> Text)
-> (EffectDeclaration Symbol Ann -> Text)
-> EffectDeclaration Symbol Ann
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EffectDeclaration Symbol Ann -> Text
forall a. Show a => a -> Text
pShowNoColor) (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (DataDeclaration Symbol Ann -> Text)
-> DataDeclaration Symbol Ann
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.toStrict (Text -> Text)
-> (DataDeclaration Symbol Ann -> Text)
-> DataDeclaration Symbol Ann
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDeclaration Symbol Ann -> Text
forall a. Show a => a -> Text
pShowNoColor) Decl Symbol Ann
decl
  AnnotatedFoldRanges Text
txt -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
txt
  DisplayDebugNameDiff NameChanges {[(Name, Referent)]
termNameAdds :: [(Name, Referent)]
$sel:termNameAdds:NameChanges :: NameChanges -> [(Name, Referent)]
termNameAdds, [(Name, Referent)]
termNameRemovals :: [(Name, Referent)]
$sel:termNameRemovals:NameChanges :: NameChanges -> [(Name, Referent)]
termNameRemovals, [(Name, TypeReference)]
typeNameAdds :: [(Name, TypeReference)]
$sel:typeNameAdds:NameChanges :: NameChanges -> [(Name, TypeReference)]
typeNameAdds, [(Name, TypeReference)]
typeNameRemovals :: [(Name, TypeReference)]
$sel:typeNameRemovals:NameChanges :: NameChanges -> [(Name, TypeReference)]
typeNameRemovals} -> do
    let referentText :: Referent -> Pretty ColorText
referentText =
          -- We don't use the constructor type in the actual output here, so there's no
          -- point in looking up the correct one.
          Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (Referent -> Text) -> Referent -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Referent -> Text
Referent.toText (Referent -> Text) -> (Referent -> Referent) -> Referent -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity Referent -> Referent
forall a. Identity a -> a
runIdentity (Identity Referent -> Referent)
-> (Referent -> Identity Referent) -> Referent -> Referent
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReference -> Identity ConstructorType)
-> Referent -> Identity Referent
forall (m :: * -> *).
Applicative m =>
(TypeReference -> m ConstructorType) -> Referent -> m Referent
Cv.referent2to1 (\TypeReference
_ref -> ConstructorType -> Identity ConstructorType
forall a. a -> Identity a
Identity ConstructorType
CT.Data)
    let referenceText :: TypeReference -> Pretty ColorText
referenceText = Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (TypeReference -> Text) -> TypeReference -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Text
Reference.toText (TypeReference -> Text)
-> (TypeReference -> TypeReference) -> TypeReference -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> TypeReference
Cv.reference2to1
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> [[Pretty ColorText]] -> Pretty ColorText
P.columnNHeader
        [Pretty ColorText
"Kind", Pretty ColorText
"Name", Pretty ColorText
"Change", Pretty ColorText
"Ref"]
        ( ([(Name, Referent)]
termNameAdds [(Name, Referent)]
-> ((Name, Referent) -> [Pretty ColorText]) -> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, Referent
ref) -> [Pretty ColorText
"Term", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Pretty ColorText
"Added", Referent -> Pretty ColorText
referentText Referent
ref])
            [[Pretty ColorText]]
-> [[Pretty ColorText]] -> [[Pretty ColorText]]
forall a. Semigroup a => a -> a -> a
<> ([(Name, Referent)]
termNameRemovals [(Name, Referent)]
-> ((Name, Referent) -> [Pretty ColorText]) -> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, Referent
ref) -> [Pretty ColorText
"Term", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Pretty ColorText
"Removed", Referent -> Pretty ColorText
referentText Referent
ref])
            [[Pretty ColorText]]
-> [[Pretty ColorText]] -> [[Pretty ColorText]]
forall a. Semigroup a => a -> a -> a
<> ([(Name, TypeReference)]
typeNameAdds [(Name, TypeReference)]
-> ((Name, TypeReference) -> [Pretty ColorText])
-> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, TypeReference
ref) -> [Pretty ColorText
"Type", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Pretty ColorText
"Added", TypeReference -> Pretty ColorText
referenceText TypeReference
ref])
            [[Pretty ColorText]]
-> [[Pretty ColorText]] -> [[Pretty ColorText]]
forall a. Semigroup a => a -> a -> a
<> ([(Name, TypeReference)]
typeNameRemovals [(Name, TypeReference)]
-> ((Name, TypeReference) -> [Pretty ColorText])
-> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
n, TypeReference
ref) -> [Pretty ColorText
"Type", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Pretty ColorText
"Removed", TypeReference -> Pretty ColorText
referenceText TypeReference
ref])
        )
  DisplayDebugCompletions [Completion]
completions ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2
        ( [Completion]
completions [Completion]
-> (Completion -> (Pretty ColorText, Pretty ColorText))
-> [(Pretty ColorText, Pretty ColorText)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Completion
comp ->
            let isCompleteTxt :: Pretty ColorText
isCompleteTxt =
                  if Completion -> Bool
Completion.isFinished Completion
comp
                    then Pretty ColorText
"*"
                    else Pretty ColorText
""
             in (Pretty ColorText
isCompleteTxt, String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (Completion -> String
Completion.replacement Completion
comp))
        )
  DisplayDebugLSPNameCompletions [(Text, Name, LabeledDependency)]
completions ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> [[Pretty ColorText]] -> Pretty ColorText
P.columnNHeader
        [Pretty ColorText
"Matching Path", Pretty ColorText
"Name", Pretty ColorText
"Hash"]
        ( [(Text, Name, LabeledDependency)]
completions [(Text, Name, LabeledDependency)]
-> ((Text, Name, LabeledDependency) -> [Pretty ColorText])
-> [[Pretty ColorText]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Text
pathText, Name
fqn, LabeledDependency
ld) ->
            let ldRef :: Pretty (SyntaxText' TypeReference)
ldRef = case LabeledDependency
ld of
                  LD.TermReferent Referent
ref -> Int -> Referent -> Pretty (SyntaxText' TypeReference)
prettyReferent Int
10 Referent
ref
                  LD.TypeReference TypeReference
ref -> Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference Int
10 TypeReference
ref
             in [Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
pathText, Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
fqn, Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor Pretty (SyntaxText' TypeReference)
ldRef]
        )
  DebugDisplayFuzzyOptions Text
argDesc [String]
fuzzyOptions ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Text
FZFResolvers.fuzzySelectHeader Text
argDesc), Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, ListLike s Char, IsString s) =>
f (Pretty s) -> Pretty s
P.bulleted (String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (String -> Pretty ColorText) -> [String] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [String]
fuzzyOptions)]
  Output
DebugFuzzyOptionsNoResolver -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"No resolver found for fuzzy options in this slot."
  Output
ClearScreen -> do
    IO ()
ANSI.clearScreen
    Int -> Int -> IO ()
ANSI.setCursorPosition Int
0 Int
0
    pure Pretty ColorText
forall a. Monoid a => a
mempty
  PulledEmptyBranch ReadRemoteNamespace RemoteProjectBranch
remote ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ReadRemoteNamespace RemoteProjectBranch -> Pretty ColorText
prettyReadRemoteNamespace ReadRemoteNamespace RemoteProjectBranch
remote) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has some history, but is currently empty."
  CreatedProject Bool
nameWasRandomlyGenerated ProjectName
projectName ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      if Bool
nameWasRandomlyGenerated
        then
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"🎉 I've created the project with the randomly-chosen name"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
projectName
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"(use"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.projectRenameInputPattern [Pretty ColorText
"<new-name>"]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to change it)."
        else
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"🎉 I've created the project" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
projectName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  CreatedProjectBranch CreatedProjectBranchFrom
from ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    case CreatedProjectBranchFrom
from of
      CreatedProjectBranchFrom'LooseCode Absolute
path ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
            ( Pretty ColorText
"Done. I've created the"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"branch from the namespace"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Absolute -> Pretty ColorText
prettyAbsolute Absolute
path
            )
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
      CreatedProjectBranchFrom
CreatedProjectBranchFrom'Nothingness ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Done. I've created an empty branch" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
              ( Pretty ColorText
"Use"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.mergeInputPattern [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName (Text -> ProjectBranchName
UnsafeProjectBranchName Text
"somebranch")]
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to initialize this branch."
              )
      CreatedProjectBranchFrom'OtherBranch (ProjectAndBranch Project
otherProject ProjectBranch
otherBranch) ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
            ( Pretty ColorText
"Done. I've created the"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"branch based off"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch (Project
otherProject Project -> Getting ProjectName Project ProjectName -> ProjectName
forall s a. s -> Getting a s a -> a
^. Getting ProjectName Project ProjectName
#name) (ProjectBranch
otherBranch ProjectBranch
-> Getting ProjectBranchName ProjectBranch ProjectBranchName
-> ProjectBranchName
forall s a. s -> Getting a s a -> a
^. Getting ProjectBranchName ProjectBranch ProjectBranchName
#name))
            )
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
      CreatedProjectBranchFrom'ParentBranch ProjectBranchName
parentBranch ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
            ( Pretty ColorText
"Done. I've created the"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName (ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ProjectAndBranch ProjectName ProjectBranchName
-> Getting
     ProjectBranchName
     (ProjectAndBranch ProjectName ProjectBranchName)
     ProjectBranchName
-> ProjectBranchName
forall s a. s -> Getting a s a -> a
^. Getting
  ProjectBranchName
  (ProjectAndBranch ProjectName ProjectBranchName)
  ProjectBranchName
#branch)
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"branch based off of"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
parentBranch
            )
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
              ( Pretty ColorText
"To merge your work back into the"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
parentBranch
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"branch, first"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.projectSwitch [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
parentBranch]
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"then"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.mergeInputPattern [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName (ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ProjectAndBranch ProjectName ProjectBranchName
-> Getting
     ProjectBranchName
     (ProjectAndBranch ProjectName ProjectBranchName)
     ProjectBranchName
-> ProjectBranchName
forall s a. s -> Getting a s a -> a
^. Getting
  ProjectBranchName
  (ProjectAndBranch ProjectName ProjectBranchName)
  ProjectBranchName
#branch)] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
              )
  CreatedRemoteProject URI
host (ProjectAndBranch ProjectName
projectName ProjectBranchName
_) ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I just created"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
projectName
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  CreatedRemoteProjectBranch URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I just created" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  RemoteProjectBranchIsUpToDate URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is already up-to-date."
  InvalidProjectName Text
name -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is not a valid project name."))
  InvalidProjectBranchName Text
name -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is not a valid branch name."))
  ProjectNameAlreadyExists ProjectName
name ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"Project" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"already exists."
  ProjectNameRequiresUserSlug ProjectName
name ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectName -> Pretty ColorText
prettyProjectName ProjectName
name
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"requires a username, as in"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName (forall source target.
(HasCallStack, TryFrom source target, Show source, Typeable source,
 Typeable target) =>
source -> target
unsafeFrom @Text Text
"@unison/base")
  ProjectAndBranchNameAlreadyExists ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"already exists."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"You can switch to it with "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleEOS InputPattern
IP.projectSwitch [ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch]
  Output
NotOnProjectBranch -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"You are not currently on a branch.")
  NoAssociatedRemoteProject URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"isn't associated with any project on" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  NoAssociatedRemoteProjectBranch URI
host (ProjectAndBranch Project
project ProjectBranch
branch) ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch (Project
project Project -> Getting ProjectName Project ProjectName -> ProjectName
forall s a. s -> Getting a s a -> a
^. Getting ProjectName Project ProjectName
#name) (ProjectBranch
branch ProjectBranch
-> Getting ProjectBranchName ProjectBranch ProjectBranchName
-> ProjectBranchName
forall s a. s -> Getting a s a -> a
^. Getting ProjectBranchName ProjectBranch ProjectBranchName
#name))
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"isn't associated with any branch on"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  LocalProjectDoesntExist ProjectName
project ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"does not exist."
  LocalProjectBranchDoesntExist ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"does not exist."
  LocalProjectNorProjectBranchExist ProjectName
project ProjectBranchName
branch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"Neither project"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"nor branch"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"exists."
  RemoteProjectDoesntExist URI
host ProjectName
project ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"does not exist on" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  RemoteProjectBranchDoesntExist URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"does not exist on" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
  RemoteProjectBranchDoesntExist'Push URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    let push :: Pretty ColorText
push = Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InputPattern -> Pretty ColorText
IP.patternName (InputPattern -> Pretty ColorText)
-> InputPattern -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ InputPattern
IP.push
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The previous push target named"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has been deleted from"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (URI -> Pretty ColorText
prettyShareURI URI
host Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"I've deleted the invalid push target."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Run the"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
push
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"command again to push to a new target."
  RemoteProjectBranchHeadMismatch URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has some history that I don't know about."
  RemoteProjectPublishedReleaseCannotBeChanged URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"The release"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has already been published and cannot be changed."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Consider making a new release instead."
  RemoteProjectReleaseIsDeprecated URI
host ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"The release"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
projectAndBranch
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"on"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> URI -> Pretty ColorText
prettyShareURI URI
host
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has been deprecated."
  Unauthorized Text
message ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text
"Unauthorized: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
message)
  ServantClientError ClientError
err ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure case ClientError
err of
      Servant.ConnectionError SomeException
exception ->
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText -> Maybe (Pretty ColorText) -> Pretty ColorText
forall a. a -> Maybe a -> a
fromMaybe Pretty ColorText
"Something went wrong with the connection. Try again?" do
            case SomeException -> ConnectionError
ServantClientUtils.classifyConnectionError SomeException
exception of
              ConnectionError
ServantClientUtils.ConnectionError'Offline -> Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just Pretty ColorText
"You appear to be offline."
              ServantClientUtils.ConnectionError'SomethingElse HttpExceptionContent
_ -> Maybe (Pretty ColorText)
forall a. Maybe a
Nothing
              ServantClientUtils.ConnectionError'SomethingEntirelyUnexpected SomeException
_ -> Maybe (Pretty ColorText)
forall a. Maybe a
Nothing
      Servant.DecodeFailure Text
message Response
response ->
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Huh, I failed to decode a response from the server."
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
message)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Here is the full response."
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Response -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.pshown Response
response)
      Servant.FailureResponse RequestF () (BaseUrl, ByteString)
request Response
response ->
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Oops, I received an unexpected status code from the server."
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Here is the request."
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (RequestF () (BaseUrl, ByteString) -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.pshown RequestF () (BaseUrl, ByteString)
request)
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Here is the full response."
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Response -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.pshown Response
response)
      Servant.InvalidContentTypeHeader Response
response -> Response -> Pretty ColorText
forall {s} {a}.
(Item s ~ Char, ListLike s Char, IsString s, Show a) =>
a -> Pretty s
wrongContentType Response
response
      Servant.UnsupportedContentType MediaType
_mediaType Response
response -> Response -> Pretty ColorText
forall {s} {a}.
(Item s ~ Char, ListLike s Char, IsString s, Show a) =>
a -> Pretty s
wrongContentType Response
response
    where
      wrongContentType :: a -> Pretty s
wrongContentType a
response =
        Pretty s -> Pretty s
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty s
"Huh, the server sent me the wrong content type."
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Pretty s
forall s. IsString s => Pretty s
P.newline
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Pretty s
forall s. IsString s => Pretty s
P.newline
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Pretty s -> Pretty s
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty s
"Here is the full response."
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Pretty s
forall s. IsString s => Pretty s
P.newline
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Pretty s
forall s. IsString s => Pretty s
P.newline
          Pretty s -> Pretty s -> Pretty s
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty s -> Pretty s
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (a -> Pretty s
forall a s. (Show a, IsString s) => a -> Pretty s
P.pshown a
response)
  MarkdownOut Text
md -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
md
  DownloadedEntities Int
n -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Downloaded" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
forall n s. (Show n, Num n, IsString s) => n -> Pretty s
P.num Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"entities."))
  UploadedEntities Int
n -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Uploaded" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
forall n s. (Show n, Num n, IsString s) => n -> Pretty s
P.num Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"entities."))
  NotImplementedYet Text
message -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Not implemented:" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
message))
  DraftingRelease ProjectBranchName
branch Semver
ver ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"😎 Great! I've created a draft release for you at " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch)
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
          ( Pretty ColorText
"You can create a"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked Pretty ColorText
"ReleaseNotes : Doc")
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"in this branch to give an overview of the release."
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"It'll automatically show up on Unison Share when you publish."
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
          ( Pretty ColorText
"When ready to release"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Semver -> Pretty ColorText
prettySemver Semver
ver
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to the world,"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.push
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the release to Unison Share, navigate to the release, and click \"Publish\"."
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( Pretty ColorText
"if you get pulled away from drafting your release, you can always get back to it with "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.projectSwitch [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch]
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
  CannotCreateReleaseBranchWithBranchCommand ProjectBranchName
branch Semver
ver ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"Branch names like" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"are reserved for releases.")
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( Pretty ColorText
"to download an existing release, try "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.clone [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch]
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText
"to draft a new release, try " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.releaseDraft [Semver -> Pretty ColorText
prettySemver Semver
ver])
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
  Output
CalculatingDiff -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Calculating diff...")
  AmbiguousCloneLocal ProjectAndBranch ProjectName ProjectBranchName
project ProjectAndBranch ProjectName ProjectBranchName
branch -> do
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Pretty ColorText
"I'm not sure if you wanted to clone as the branch"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
branch
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or as the branch"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Could you be more specific?"
        )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName (ProjectAndBranch ProjectName ProjectBranchName
branch ProjectAndBranch ProjectName ProjectBranchName
-> Getting
     ProjectBranchName
     (ProjectAndBranch ProjectName ProjectBranchName)
     ProjectBranchName
-> ProjectBranchName
forall s a. s -> Getting a s a -> a
^. Getting
  ProjectBranchName
  (ProjectAndBranch ProjectName ProjectBranchName)
  ProjectBranchName
#branch)
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"refers to the branch"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( ProjectName -> Pretty ColorText
prettyProjectNameSlash (ProjectAndBranch ProjectName ProjectBranchName
project ProjectAndBranch ProjectName ProjectBranchName
-> Getting
     ProjectName
     (ProjectAndBranch ProjectName ProjectBranchName)
     ProjectName
-> ProjectName
forall s a. s -> Getting a s a -> a
^. Getting
  ProjectName
  (ProjectAndBranch ProjectName ProjectBranchName)
  ProjectName
#project)
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"refers to"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the branch"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
          )
  AmbiguousCloneRemote ProjectName
project (ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch) ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Pretty ColorText
"I'm not sure if you wanted to clone the branch"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch)
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"or the project"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Could you be more specific?"
        )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip
          ( ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
branch
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"refers to the branch"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
currentProject ProjectBranchName
branch) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (ProjectName -> Pretty ColorText
prettyProjectNameSlash ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"refers to the project" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
project Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."))
  ClonedProjectBranch ProjectAndBranch ProjectName ProjectBranchName
remote ProjectAndBranch ProjectName ProjectBranchName
local ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"Cloned"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> if ProjectAndBranch ProjectName ProjectBranchName
remote ProjectAndBranch ProjectName ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName -> Bool
forall a. Eq a => a -> a -> Bool
== ProjectAndBranch ProjectName ProjectBranchName
local
          then Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
remote Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
          else ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
remote Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"as" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
local Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  RenamedProject ProjectName
oldName ProjectName
newName ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      if ProjectName
oldName ProjectName -> ProjectName -> Bool
forall a. Eq a => a -> a -> Bool
== ProjectName
newName
        then ProjectName -> Pretty ColorText
prettyProjectName ProjectName
oldName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is already named" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
oldName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"!") Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"😄"
        else Pretty ColorText
"Ok, I renamed" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectName -> Pretty ColorText
prettyProjectName ProjectName
oldName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectName -> Pretty ColorText
prettyProjectName ProjectName
newName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  RenamedProjectBranch ProjectName
projectName ProjectBranchName
oldBranchName ProjectBranchName
newBranchName ->
    let oldProjectAndBranchName :: Pretty ColorText
oldProjectAndBranchName = ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
projectName ProjectBranchName
oldBranchName)
        newProjectAndBranchName :: Pretty ColorText
newProjectAndBranchName = ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
projectName ProjectBranchName
newBranchName)
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          if ProjectBranchName
oldBranchName ProjectBranchName -> ProjectBranchName -> Bool
forall a. Eq a => a -> a -> Bool
== ProjectBranchName
newBranchName
            then Pretty ColorText
oldProjectAndBranchName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is already named" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText
newProjectAndBranchName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"!") Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"😄"
            else Pretty ColorText
"Ok, I renamed" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
oldProjectAndBranchName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText
newProjectAndBranchName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  CantRenameBranchTo ProjectBranchName
branch ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"You can't rename a branch to" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  Output
FetchingLatestReleaseOfBase ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I'll now fetch the latest version of the base Unison library..."
  Output
FailedToFetchLatestReleaseOfBase ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Sorry something went wrong while fetching the library."
  Output
HappyCoding -> do
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"🎨 Type `ui` to explore this project's code in your browser."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"🔭 Discover libraries at https://share.unison-lang.org")
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"📖 Use `help-topic projects` to learn more about projects."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Write your first Unison code with UCM:"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN
          Width
2
          ( Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"1. Open scratch.u."
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"2. Write some Unison code and save the file."
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"3. In UCM, type `add` to save it to your new project."
          )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"🎉 🥳 Happy coding!"
  ProjectHasNoReleases ProjectName
projectName ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ ProjectName -> Pretty ColorText
prettyProjectName ProjectName
projectName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has no releases."
  Output
UpdateLookingForDependents -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Okay, I'm searching the branch for code that needs to be updated..."
  Output
UpdateStartTypechecking -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"That's done. Now I'm making sure everything typechecks..."
  Output
UpdateTypecheckingSuccess -> Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Everything typechecks, so I'm saving the results..."
  Output
UpdateTypecheckingFailure ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"Typechecking failed. I've updated your scratch file with the definitions that need fixing."
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Once the file is compiling, try"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.update
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"again."
  UpdateIncompleteConstructorSet UpdateOrUpgrade
operation Name
typeName Map ConstructorId Name
_ctorMap Maybe Int
_expectedCount ->
    let operationName :: Pretty ColorText
operationName = case UpdateOrUpgrade
operation of UpdateOrUpgrade
E.UOUUpdate -> Pretty ColorText
"update"; UpdateOrUpgrade
E.UOUUpgrade -> Pretty ColorText
"upgrade"
     in Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"I couldn't complete the"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
operationName
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"because the type"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has unnamed constructors."
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"(I currently need each constructor to have a name somewhere under the type name.)",
              Pretty ColorText
"",
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                Pretty ColorText
"You can use"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNAfterNewline Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.view [Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName])
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNAfterNewline Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.aliasTerm [Pretty ColorText
"<hash>", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".<ConstructorName>"])
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to give names to each constructor, and then try the"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
operationName
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"again."
            ]
  UpgradeFailure ProjectBranchName
main ProjectBranchName
temp String
path NameSegment
old NameSegment
new ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"I couldn't automatically upgrade"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
old)
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
new) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"However, I've added the definitions that need attention to the top of"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (String -> Pretty ColorText
prettyFilePath String
path Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"When you're done, you can run",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleNoBackticks InputPattern
IP.upgradeCommitInputPattern []),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"to merge your changes back into"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
main
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and delete the temporary branch. Or, if you decide to cancel the upgrade instead, you can run",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleNoBackticks InputPattern
IP.deleteBranch [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
temp]),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"to delete the temporary branch and switch back to"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
main Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
        ]
  UpgradeSuccess NameSegment
old NameSegment
new ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I upgraded"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
old)
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
new) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and removed"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
old) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  MergeFailure String
path MergeSourceAndTarget
aliceAndBob ProjectBranchName
temp ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"I couldn't automatically merge"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> MergeSource -> Pretty ColorText
prettyMergeSource MergeSourceAndTarget
aliceAndBob.bob
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"into"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName MergeSourceAndTarget
aliceAndBob.alice Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"However, I've added the definitions that need attention to the top of"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (String -> Pretty ColorText
prettyFilePath String
path Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"When you're done, you can run",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleNoBackticks InputPattern
IP.mergeCommitInputPattern []),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"to merge your changes back into"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName MergeSourceAndTarget
aliceAndBob.alice.branch
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and delete the temporary branch. Or, if you decide to cancel the merge instead, you can run",
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleNoBackticks InputPattern
IP.deleteBranch [ProjectBranchName -> Pretty ColorText
prettySlashProjectBranchName ProjectBranchName
temp]),
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"to delete the temporary branch and switch back to"
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectBranchName -> Pretty ColorText
prettyProjectBranchName MergeSourceAndTarget
aliceAndBob.alice.branch Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
        ]
  MergeSuccess MergeSourceAndTarget
aliceAndBob ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I merged"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> MergeSource -> Pretty ColorText
prettyMergeSource MergeSourceAndTarget
aliceAndBob.bob
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"into"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName MergeSourceAndTarget
aliceAndBob.alice Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  MergeSuccessFastForward MergeSourceAndTarget
aliceAndBob ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I fast-forward merged"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> MergeSource -> Pretty ColorText
prettyMergeSource MergeSourceAndTarget
aliceAndBob.bob
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"into"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName MergeSourceAndTarget
aliceAndBob.alice Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  InstalledLibdep ProjectAndBranch ProjectName ProjectBranchName
libdep NameSegment
segment ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I installed"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
libdep
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"as"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (NameSegment -> Text
NameSegment.toEscapedText NameSegment
segment) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  Output
NoUpgradeInProgress ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"It doesn't look like there's an upgrade in progress."
  UseLibInstallNotPull ProjectAndBranch ProjectName ProjectBranchName
libdep ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"The use of"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.pull
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to install libraries is now deprecated. Going forward, you can use"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.libInstallInputPattern [ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName ProjectAndBranch ProjectName ProjectBranchName
libdep] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
  PullIntoMissingBranch ReadRemoteNamespace RemoteProjectBranch
source (ProjectAndBranch Maybe ProjectName
maybeTargetProject ProjectBranchName
targetBranch) ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"I think you want to merge"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
sourcePretty
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"into the"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
targetPretty
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"branch, but it doesn't exist. If you want, you can create it with"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.branchEmptyInputPattern [Pretty ColorText
targetPretty] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and then"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.pull
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"again."
    where
      sourcePretty :: Pretty ColorText
sourcePretty = ReadRemoteNamespace RemoteProjectBranch -> Pretty ColorText
prettyReadRemoteNamespace ReadRemoteNamespace RemoteProjectBranch
source
      targetPretty :: Pretty ColorText
targetPretty =
        case Maybe ProjectName
maybeTargetProject of
          Maybe ProjectName
Nothing -> ProjectBranchName -> Pretty ColorText
prettyProjectBranchName ProjectBranchName
targetBranch
          Just ProjectName
targetProject -> ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch ProjectName
targetProject ProjectBranchName
targetBranch)
  Output
NoMergeInProgress ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"It doesn't look like there's a merge in progress."
  Output'DebugSynhashTerm TypeReference
ref Hash
synhash Text
filename ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText
"Hash: "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference Int
120 TypeReference
ref)
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Synhash: "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash -> Pretty ColorText
forall s. IsString s => Hash -> Pretty s
prettyHash Hash
synhash
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Synhash tokens: "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
filename
  ConflictedDefn Text
operation Defn (Conflicted Name Referent) (Conflicted Name TypeReference)
defn ->
    Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
      ( Pretty ColorText
"This branch has more than one" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> case Defn (Conflicted Name Referent) (Conflicted Name TypeReference)
defn of
          TermDefn (Conflicted Name
name NESet Referent
_refs) -> Pretty ColorText
"term with the name" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
          TypeDefn (Conflicted Name
name NESet TypeReference
_refs) -> Pretty ColorText
"type with the name" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
      )
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Please delete or rename all but one of them, then try the"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
operation
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"again."
  IncoherentDeclDuringMerge MergeSourceOrTarget
aliceOrBob IncoherentDeclReason
reason ->
    case IncoherentDeclReason
reason of
      -- Note [ConstructorAliasMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'ConstructorAlias Name
typeName Name
conName1 Name
conName2 ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the merge:",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"On"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the type"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has a constructor with multiple names, and I can't perform a merge in this situation:",
            Pretty ColorText
"",
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, ListLike s Char, IsString s) =>
f (Pretty s) -> Pretty s
P.bulleted [Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName1, Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName2]),
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Please delete all but one name for each constructor, and then try merging again."
          ]
      -- Note [MissingConstructorNameMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'MissingConstructorName Name
name ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the merge:",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"On"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the type"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has some constructors with missing names, and I can't perform a merge in this situation.",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"You can use"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.view [Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name]
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.aliasTerm [Pretty ColorText
"<hash>", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".<ConstructorName>"]
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to give names to each unnamed constructor, and then try the merge again."
          ]
      -- Note [NestedDeclAliasMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'NestedDeclAlias Name
shorterName Name
longerName ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"On"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the type"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
longerName
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is an alias of"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
shorterName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"I'm not able to perform a merge when a type exists nested under an alias of itself. Please separate them or"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"delete one copy, and then try merging again."
      -- Note [StrayConstructorMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'StrayConstructor TermReferenceId
_typeRef Name
name ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"Sorry, I wasn't able to perform the merge, because I need all constructor names to be nested somewhere"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"beneath the corresponding type name.",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"On"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (MergeSourceOrTarget -> Pretty ColorText
prettyMergeSourceOrTarget MergeSourceOrTarget
aliceOrBob Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
",")
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"the constructor"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is not nested beneath the corresponding type name. Please either use"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.moveAll
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to move it, or if it's an extra copy, you can simply"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.delete
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"it. Then try the merge again."
          ]
  IncoherentDeclDuringUpdate IncoherentDeclReason
reason ->
    case IncoherentDeclReason
reason of
      -- Note [ConstructorAliasMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'ConstructorAlias Name
typeName Name
conName1 Name
conName2 ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the update:",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"The type"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has a constructor with multiple names, and I can't perform an update in this situation:",
            Pretty ColorText
"",
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, ListLike s Char, IsString s) =>
f (Pretty s) -> Pretty s
P.bulleted [Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName1, Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName2]),
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Please delete all but one name for each constructor, and then try updating again."
          ]
      -- Note [MissingConstructorNameMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'MissingConstructorName Name
name ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Sorry, I wasn't able to perform the update:",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"The type"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has some constructors with missing names, and I can't perform an update in this situation.",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"You can use"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.view [Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name]
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.aliasTerm [Pretty ColorText
"<hash>", Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".<ConstructorName>"]
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to give names to each unnamed constructor, and then try the update again."
          ]
      -- Note [NestedDeclAliasMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'NestedDeclAlias Name
shorterName Name
longerName ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"The type"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
longerName
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is an alias of"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
shorterName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"I'm not able to perform an update when a type exists nested under an alias of itself. Please separate"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"them or delete one copy, and then try updating again."
      -- Note [StrayConstructorMessage] If you change this, also change the other similar ones
      IncoherentDeclReason'StrayConstructor TermReferenceId
_typeRef Name
name ->
        Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"Sorry, I wasn't able to perform the update, because I need all constructor names to be nested somewhere"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"beneath the corresponding type name.",
            Pretty ColorText
"",
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Pretty ColorText
"The constructor"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"is not nested beneath the corresponding type name. Please either use"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.moveAll
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to move it, or if it's an extra copy, you can simply"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.delete
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"it. Then try the update again."
          ]

prettyShareError :: ShareError -> Pretty
prettyShareError :: ShareError -> Pretty ColorText
prettyShareError =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> (ShareError -> Pretty ColorText)
-> ShareError
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    ShareErrorDownloadEntities DownloadEntitiesError
err -> DownloadEntitiesError -> Pretty ColorText
prettyDownloadEntitiesError DownloadEntitiesError
err
    ShareErrorGetCausalHashByPath GetCausalHashByPathError
err -> GetCausalHashByPathError -> Pretty ColorText
prettyGetCausalHashByPathError GetCausalHashByPathError
err
    ShareErrorPull PullError
err -> PullError -> Pretty ColorText
prettyPullError PullError
err
    ShareErrorTransport CodeserverTransportError
err -> CodeserverTransportError -> Pretty ColorText
prettyTransportError CodeserverTransportError
err
    ShareErrorUploadEntities UploadEntitiesError
err -> UploadEntitiesError -> Pretty ColorText
prettyUploadEntitiesError UploadEntitiesError
err
    ShareError
ShareExpectedSquashedHead -> Pretty ColorText
"The server failed to provide a squashed branch head when requested. Please report this as a bug to the Unison team."

prettyDownloadEntitiesError :: Share.DownloadEntitiesError -> Pretty
prettyDownloadEntitiesError :: DownloadEntitiesError -> Pretty ColorText
prettyDownloadEntitiesError = \case
  Share.DownloadEntitiesNoReadPermission RepoInfo
repoInfo -> RepoInfo -> Pretty ColorText
noReadPermissionForRepo RepoInfo
repoInfo
  Share.DownloadEntitiesInvalidRepoInfo Text
err RepoInfo
repoInfo -> Text -> RepoInfo -> Pretty ColorText
invalidRepoInfo Text
err RepoInfo
repoInfo
  Share.DownloadEntitiesUserNotFound Text
userHandle -> RepoInfo -> Pretty ColorText
shareUserNotFound (Text -> RepoInfo
Share.RepoInfo Text
userHandle)
  Share.DownloadEntitiesProjectNotFound Text
project -> Text -> Pretty ColorText
shareProjectNotFound Text
project
  Share.DownloadEntitiesEntityValidationFailure EntityValidationError
err -> EntityValidationError -> Pretty ColorText
prettyEntityValidationFailure EntityValidationError
err

prettyGetCausalHashByPathError :: Share.GetCausalHashByPathError -> Pretty
prettyGetCausalHashByPathError :: GetCausalHashByPathError -> Pretty ColorText
prettyGetCausalHashByPathError = \case
  Share.GetCausalHashByPathErrorNoReadPermission Path
sharePath -> Path -> Pretty ColorText
noReadPermissionForPath Path
sharePath
  Share.GetCausalHashByPathErrorInvalidRepoInfo Text
err RepoInfo
repoInfo -> Text -> RepoInfo -> Pretty ColorText
invalidRepoInfo Text
err RepoInfo
repoInfo
  Share.GetCausalHashByPathErrorUserNotFound RepoInfo
repoInfo -> RepoInfo -> Pretty ColorText
shareUserNotFound RepoInfo
repoInfo

prettyPullError :: Share.PullError -> Pretty
prettyPullError :: PullError -> Pretty ColorText
prettyPullError = \case
  Share.PullError'DownloadEntities DownloadEntitiesError
err -> DownloadEntitiesError -> Pretty ColorText
prettyDownloadEntitiesError DownloadEntitiesError
err
  Share.PullError'GetCausalHash GetCausalHashByPathError
err -> GetCausalHashByPathError -> Pretty ColorText
prettyGetCausalHashByPathError GetCausalHashByPathError
err
  Share.PullError'NoHistoryAtPath Path
sharePath ->
    Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server didn't find anything at" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path -> Pretty ColorText
prettySharePath Path
sharePath

prettyUploadEntitiesError :: Share.UploadEntitiesError -> Pretty
prettyUploadEntitiesError :: UploadEntitiesError -> Pretty ColorText
prettyUploadEntitiesError = \case
  Share.UploadEntitiesError'EntityValidationFailure EntityValidationError
validationFailureErr -> EntityValidationError -> Pretty ColorText
prettyEntityValidationFailure EntityValidationError
validationFailureErr
  Share.UploadEntitiesError'HashMismatchForEntity (Share.HashMismatchForEntity {Hash32
supplied :: Hash32
$sel:supplied:HashMismatchForEntity :: HashMismatchForEntity -> Hash32
supplied, Hash32
computed :: Hash32
$sel:computed:HashMismatchForEntity :: HashMismatchForEntity -> Hash32
computed}) ->
    Hash32 -> Hash32 -> Pretty ColorText
hashMismatchFromShare Hash32
supplied Hash32
computed
  Share.UploadEntitiesError'InvalidRepoInfo Text
err RepoInfo
repoInfo -> Text -> RepoInfo -> Pretty ColorText
invalidRepoInfo Text
err RepoInfo
repoInfo
  Share.UploadEntitiesError'NeedDependencies NeedDependencies Hash32
dependencies -> NeedDependencies Hash32 -> Pretty ColorText
needDependencies NeedDependencies Hash32
dependencies
  Share.UploadEntitiesError'NoWritePermission RepoInfo
repoInfo -> RepoInfo -> Pretty ColorText
noWritePermissionForRepo RepoInfo
repoInfo
  Share.UploadEntitiesError'ProjectNotFound Text
project -> Text -> Pretty ColorText
shareProjectNotFound Text
project
  Share.UploadEntitiesError'UserNotFound Text
userHandle -> RepoInfo -> Pretty ColorText
shareUserNotFound (Text -> RepoInfo
Share.RepoInfo Text
userHandle)

prettyEntityValidationFailure :: Share.EntityValidationError -> Pretty
prettyEntityValidationFailure :: EntityValidationError -> Pretty ColorText
prettyEntityValidationFailure = \case
  Share.EntityHashMismatch EntityType
entityType (Share.HashMismatchForEntity {Hash32
$sel:supplied:HashMismatchForEntity :: HashMismatchForEntity -> Hash32
supplied :: Hash32
supplied, Hash32
$sel:computed:HashMismatchForEntity :: HashMismatchForEntity -> Hash32
computed :: Hash32
computed}) ->
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The hash associated with the given " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> EntityType -> Pretty ColorText
prettyEntityType EntityType
entityType Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" entity is incorrect.",
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The associated hash is: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
supplied,
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The computed hash is: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
computed,
        Pretty ColorText
"",
        Pretty ColorText
"Please create an issue and report this to the Unison team."
      ]
  Share.UnsupportedEntityType Hash32
hash32 EntityType
entityType ->
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The entity with hash " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
hash32 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" of type " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> EntityType -> Pretty ColorText
prettyEntityType EntityType
entityType Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" is not supported by your version of ucm.",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Try upgrading to the latest version of ucm."
      ]
  Share.InvalidByteEncoding Hash32
hash32 EntityType
entityType Text
msg ->
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Failed to decode a " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> EntityType -> Pretty ColorText
prettyEntityType EntityType
entityType Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" entity with the hash " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
hash32 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".",
        Pretty ColorText
"Please create an issue and report this to the Unison team",
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The error was: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
msg
      ]
  Share.HashResolutionFailure Hash32
hash32 ->
    -- See https://github.com/unisonweb/unison/pull/4381#discussion_r1452652087 for discussion.
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Failed to resolve a referenced hash when validating the hash for " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
hash32 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".",
        Pretty ColorText
"Please create an issue and report this to the Unison team"
      ]
  where
    prettyEntityType :: EntityType -> Pretty ColorText
prettyEntityType = \case
      EntityType
Share.TermComponentType -> Pretty ColorText
"term component"
      EntityType
Share.DeclComponentType -> Pretty ColorText
"type component"
      EntityType
Share.PatchType -> Pretty ColorText
"patch"
      EntityType
Share.PatchDiffType -> Pretty ColorText
"patch diff"
      EntityType
Share.NamespaceType -> Pretty ColorText
"namespace"
      EntityType
Share.NamespaceDiffType -> Pretty ColorText
"namespace diff"
      EntityType
Share.CausalType -> Pretty ColorText
"causal"

prettyTransportError :: CodeserverTransportError -> Pretty
prettyTransportError :: CodeserverTransportError -> Pretty ColorText
prettyTransportError = \case
  DecodeFailure Text
msg Response
resp ->
    ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> ([Maybe (Pretty ColorText)] -> [Pretty ColorText])
-> [Maybe (Pretty ColorText)]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe (Pretty ColorText)] -> [Pretty ColorText]
forall a. [Maybe a] -> [a]
catMaybes)
      [ Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just (Pretty ColorText
"The server sent a response that we couldn't decode: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
msg),
        Response -> Maybe Text
responseRequestId Response
resp Maybe Text
-> (Text -> Pretty ColorText) -> Maybe (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Text
responseId -> Pretty ColorText
forall s. IsString s => Pretty s
P.newline Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Request ID: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
responseId)
      ]
  Unauthenticated BaseUrl
codeServerURL ->
    Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText
"Authentication with this code server (" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (BaseUrl -> String
Servant.showBaseUrl BaseUrl
codeServerURL) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
") is missing or expired.",
        Pretty ColorText
"Please run " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample' InputPattern
IP.authLogin Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
      ]
  PermissionDenied Text
msg -> Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.hang Pretty ColorText
"Permission denied:" (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
msg)
  UnreachableCodeserver BaseUrl
codeServerURL ->
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Unable to reach the code server hosted at:" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (BaseUrl -> String
Servant.showBaseUrl BaseUrl
codeServerURL),
        Pretty ColorText
"",
        Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Please check your network, ensure you've provided the correct location, or try again later."
      ]
  CodeserverTransportError
RateLimitExceeded -> Pretty ColorText
"Rate limit exceeded, please try again later."
  CodeserverTransportError
Timeout -> Pretty ColorText
"The code server timed-out when responding to your request. Please try again later or report an issue if the problem persists."
  UnexpectedResponse Response
resp ->
    ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> ([Maybe (Pretty ColorText)] -> [Pretty ColorText])
-> [Maybe (Pretty ColorText)]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe (Pretty ColorText)] -> [Pretty ColorText]
forall a. [Maybe a] -> [a]
catMaybes)
      [ Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just
          ( Pretty ColorText
"The server sent a "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.red (Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown (Status -> Int
Http.statusCode (Response -> Status
forall a. ResponseF a -> Status
Servant.responseStatusCode Response
resp)))
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" that we didn't expect."
          ),
        let body :: Text
body = ByteString -> Text
Text.decodeUtf8 (ByteString -> ByteString
LazyByteString.toStrict (Response -> ByteString
forall a. ResponseF a -> a
Servant.responseBody Response
resp))
         in if Text -> Bool
Text.null Text
body then Maybe (Pretty ColorText)
forall a. Maybe a
Nothing else Pretty ColorText -> Maybe (Pretty ColorText)
forall a. a -> Maybe a
Just (Pretty ColorText
forall s. IsString s => Pretty s
P.newline Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Response body: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
body),
        Response -> Maybe Text
responseRequestId Response
resp Maybe Text
-> (Text -> Pretty ColorText) -> Maybe (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Text
responseId -> Pretty ColorText
forall s. IsString s => Pretty s
P.newline Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"Request ID: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
responseId)
      ]
  where
    -- Dig the request id out of a response header.
    responseRequestId :: Servant.Response -> Maybe Text
    responseRequestId :: Response -> Maybe Text
responseRequestId =
      (ByteString -> Text) -> Maybe ByteString -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
Text.decodeUtf8 (Maybe ByteString -> Maybe Text)
-> (Response -> Maybe ByteString) -> Response -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HeaderName -> [(HeaderName, ByteString)] -> Maybe ByteString
forall a b. Eq a => a -> [(a, b)] -> Maybe b
List.lookup HeaderName
"X-RequestId" ([(HeaderName, ByteString)] -> Maybe ByteString)
-> (Response -> [(HeaderName, ByteString)])
-> Response
-> Maybe ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> [a]
Foldable.toList @Seq (Seq (HeaderName, ByteString) -> [(HeaderName, ByteString)])
-> (Response -> Seq (HeaderName, ByteString))
-> Response
-> [(HeaderName, ByteString)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Response -> Seq (HeaderName, ByteString)
forall a. ResponseF a -> Seq (HeaderName, ByteString)
Servant.responseHeaders

prettyEntityType :: Share.EntityType -> Pretty
prettyEntityType :: EntityType -> Pretty ColorText
prettyEntityType = \case
  EntityType
Share.TermComponentType -> Pretty ColorText
"term component"
  EntityType
Share.DeclComponentType -> Pretty ColorText
"type component"
  EntityType
Share.PatchType -> Pretty ColorText
"patch"
  EntityType
Share.PatchDiffType -> Pretty ColorText
"patch diff"
  EntityType
Share.NamespaceType -> Pretty ColorText
"namespace"
  EntityType
Share.NamespaceDiffType -> Pretty ColorText
"namespace diff"
  EntityType
Share.CausalType -> Pretty ColorText
"causal"

invalidRepoInfo :: Text -> Share.RepoInfo -> Pretty
invalidRepoInfo :: Text -> RepoInfo -> Pretty ColorText
invalidRepoInfo Text
err RepoInfo
repoInfo =
  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
    [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"The server doesn't recognize the codebase path UCM provided. This is probably a bug in UCM.",
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"",
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The invalid path is:\n"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (RepoInfo -> Text
Share.unRepoInfo RepoInfo
repoInfo)),
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
err
    ]

hashMismatchFromShare :: Hash32 -> Hash32 -> Pretty
hashMismatchFromShare :: Hash32 -> Hash32 -> Pretty ColorText
hashMismatchFromShare Hash32
supplied Hash32
computed =
  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
    [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Uh oh, Share double-checked the hash of something you're uploading and it didn't match.",
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Don't worry, you didn't do anything wrong, this is a bug in UCM, please report it and we'll do our best to sort it out 🤞",
      Pretty ColorText
reportBugURL,
      Pretty ColorText
"",
      Pretty ColorText
"Please include the following information in your report:",
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The hash provided by your UCM is: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
supplied,
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"The hash computed by Share is: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 Hash32
computed
    ]

pushPublicNote :: InputPattern -> Text -> [Text] -> Pretty
pushPublicNote :: InputPattern -> Text -> [Text] -> Pretty ColorText
pushPublicNote InputPattern
cmd Text
uname [Text]
ys =
  let msg :: Pretty ColorText
msg =
        [Pretty ColorText] -> Pretty ColorText
forall a. Monoid a => [a] -> a
mconcat
          [ Pretty ColorText
"Unison Share currently only supports sharing public code. ",
            Pretty ColorText
"This is done by hosting code in a public namespace under your handle.",
            Pretty ColorText
"It looks like you were trying to push directly to the" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
uname),
            Pretty ColorText
"handle. Try nesting under `public` like so: "
          ]
      pushCommand :: Pretty ColorText
pushCommand = InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExampleNoBackticks InputPattern
cmd [Path -> Pretty ColorText
prettySharePath Path
exPath]
      exPath :: Path
exPath = NonEmpty Text -> Path
Share.Path (Text
uname Text -> [Text] -> NonEmpty Text
forall a. a -> [a] -> NonEmpty a
NEList.:| Text
"public" Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: [Text]
ys)
   in [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
msg,
          Pretty ColorText
"",
          Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
4 Pretty ColorText
pushCommand
        ]

needDependencies :: Share.NeedDependencies Hash32 -> Pretty
needDependencies :: NeedDependencies Hash32 -> Pretty ColorText
needDependencies (Share.NeedDependencies NESet Hash32
hashes) =
  -- maybe todo: stuff in all the args to CheckAndSetPush
  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
    [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server was expecting to have received some stuff from UCM during that last command, but claims to have not received it."
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"(This is probably a bug in UCM.)"
        ),
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"",
      Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The hashes it expected are:\n"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ((Hash32 -> Pretty ColorText) -> [Hash32] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map Hash32 -> Pretty ColorText
forall s. IsString s => Hash32 -> Pretty s
prettyHash32 (NESet Hash32 -> [Hash32]
forall a. NESet a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NESet Hash32
hashes)))
    ]

noReadPermissionForPath :: Share.Path -> Pretty
noReadPermissionForPath :: Path -> Pretty ColorText
noReadPermissionForPath Path
sharePath =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server said you don't have permission to read" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path -> Pretty ColorText
prettySharePath Path
sharePath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")

noReadPermissionForRepo :: Share.RepoInfo -> Pretty
noReadPermissionForRepo :: RepoInfo -> Pretty ColorText
noReadPermissionForRepo RepoInfo
repoInfo =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server said you don't have permission to read" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (RepoInfo -> Pretty ColorText
prettyRepoInfo RepoInfo
repoInfo Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")

noWritePermissionForPath :: Share.Path -> Pretty
noWritePermissionForPath :: Path -> Pretty ColorText
noWritePermissionForPath Path
sharePath =
  case Path -> NonEmpty Text
Share.pathSegments Path
sharePath of
    Text
_ NEList.:| Text
"public" : [Text]
_ -> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server said you don't have permission to write" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Path -> Pretty ColorText
prettySharePath Path
sharePath Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")
    Text
uname NEList.:| [Text]
ys -> InputPattern -> Text -> [Text] -> Pretty ColorText
pushPublicNote InputPattern
IP.pushCreate Text
uname [Text]
ys

noWritePermissionForRepo :: Share.RepoInfo -> Pretty
noWritePermissionForRepo :: RepoInfo -> Pretty ColorText
noWritePermissionForRepo RepoInfo
repoInfo =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
"The server said you don't have permission to write" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (RepoInfo -> Pretty ColorText
prettyRepoInfo RepoInfo
repoInfo Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
".")

notFastForward :: Share.Path -> Pretty
notFastForward :: Path -> Pretty ColorText
notFastForward Path
path =
  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
    [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"There are some changes at" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Path -> Pretty ColorText
prettySharePath Path
path Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"that aren't in the history you pushed.",
      Pretty ColorText
"",
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"If you're sure you got the right paths, try"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
pull
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to merge these changes locally, then"
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
push
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"again."
    ]
  where
    push :: Pretty ColorText
push = Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InputPattern -> Pretty ColorText
IP.patternName (InputPattern -> Pretty ColorText)
-> InputPattern -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ InputPattern
IP.push
    pull :: Pretty ColorText
pull = Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. IsString s => Pretty s -> Pretty s
P.backticked (Pretty ColorText -> Pretty ColorText)
-> (InputPattern -> Pretty ColorText)
-> InputPattern
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InputPattern -> Pretty ColorText
IP.patternName (InputPattern -> Pretty ColorText)
-> InputPattern -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ InputPattern
IP.pull

shareProjectNotFound :: Text -> Pretty
shareProjectNotFound :: Text -> Pretty ColorText
shareProjectNotFound Text
projectShortHand =
  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
    [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText
"This project does not exist: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
projectShortHand
    ]

shareUserNotFound :: Share.RepoInfo -> Pretty
shareUserNotFound :: RepoInfo -> Pretty ColorText
shareUserNotFound RepoInfo
repoInfo =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"User" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> RepoInfo -> Pretty ColorText
prettyRepoInfo RepoInfo
repoInfo Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"does not exist.")

formatMissingStuff ::
  (Show tm, Show typ) =>
  [(HQ.HashQualified Name, tm)] ->
  [(HQ.HashQualified Name, typ)] ->
  Pretty
formatMissingStuff :: forall tm typ.
(Show tm, Show typ) =>
[(HashQualified Name, tm)]
-> [(HashQualified Name, typ)] -> Pretty ColorText
formatMissingStuff [(HashQualified Name, tm)]
terms [(HashQualified Name, typ)]
types =
  ( Bool -> Pretty ColorText -> Pretty ColorText
forall a. Monoid a => Bool -> a -> a
Monoid.unlessM ([(HashQualified Name, tm)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, tm)]
terms) (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"The following terms have a missing or corrupted type signature:"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"\n\n"
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 [(Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
name, String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (tm -> String
forall a. Show a => a -> String
show tm
ref)) | (HashQualified Name
name, tm
ref) <- [(HashQualified Name, tm)]
terms]
  )
    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> ( Bool -> Pretty ColorText -> Pretty ColorText
forall a. Monoid a => Bool -> a -> a
Monoid.unlessM ([(HashQualified Name, typ)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, typ)]
types) (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.fatalCallout (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
           Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"The following types weren't found in the codebase:"
             Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"\n\n"
             Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 [(Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
name, String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (typ -> String
forall a. Show a => a -> String
show typ
ref)) | (HashQualified Name
name, typ
ref) <- [(HashQualified Name, typ)]
types]
       )

displayOutputRewrittenFile :: (Var v) => FilePath -> [v] -> IO Pretty
displayOutputRewrittenFile :: forall v. Var v => String -> [v] -> IO (Pretty ColorText)
displayOutputRewrittenFile String
_fp [] =
  Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"😶️ I couldn't find any matches in the file."
displayOutputRewrittenFile String
fp [v]
vs = do
  let modifiedDefs :: Pretty ColorText
modifiedDefs = Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
" " (Pretty ColorText -> Pretty ColorText
P.blue (Pretty ColorText -> Pretty ColorText)
-> (v -> Pretty ColorText) -> v -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Pretty ColorText
forall v. Var v => v -> Pretty ColorText
prettyVar (v -> Pretty ColorText) -> [v] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [v]
vs)
  Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"☝️" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I found and replaced matches in these definitions: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
modifiedDefs,
        Pretty ColorText
"",
        Pretty ColorText
"The rewritten file has been added to the top of " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall a. IsString a => String -> a
fromString String
fp
      ]

displayDefinitions' ::
  (Var v) =>
  (Ord a1) =>
  PPED.PrettyPrintEnvDecl ->
  Map Reference.Reference (DisplayObject () (DD.Decl v a1)) ->
  Map Reference.Reference (DisplayObject (Type v a1) (Term v a1)) ->
  Pretty
displayDefinitions' :: forall v a1.
(Var v, Ord a1) =>
PrettyPrintEnvDecl
-> Map TypeReference (DisplayObject () (Decl v a1))
-> Map TypeReference (DisplayObject (Type v a1) (Term v a1))
-> Pretty ColorText
displayDefinitions' PrettyPrintEnvDecl
ppe0 Map TypeReference (DisplayObject () (Decl v a1))
types Map TypeReference (DisplayObject (Type v a1) (Term v a1))
terms = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' TypeReference)
-> [Pretty (SyntaxText' TypeReference)]
-> Pretty (SyntaxText' TypeReference)
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty (SyntaxText' TypeReference)
"\n\n" ([Pretty (SyntaxText' TypeReference)]
prettyTypes [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
-> [Pretty (SyntaxText' TypeReference)]
forall a. Semigroup a => a -> a -> a
<> [Pretty (SyntaxText' TypeReference)]
prettyTerms)
  where
    ppeBody :: TypeReference -> PrettyPrintEnv
ppeBody TypeReference
r = PrettyPrintEnvDecl -> TypeReference -> PrettyPrintEnv
PPE.declarationPPE PrettyPrintEnvDecl
ppe0 TypeReference
r
    ppeDecl :: PrettyPrintEnv
ppeDecl = PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.unsuffixifiedPPE PrettyPrintEnvDecl
ppe0
    prettyTerms :: [Pretty (SyntaxText' TypeReference)]
prettyTerms =
      (((HashQualified Name, TypeReference),
  DisplayObject (Type v a1) (Term v a1))
 -> Pretty (SyntaxText' TypeReference))
-> [((HashQualified Name, TypeReference),
     DisplayObject (Type v a1) (Term v a1))]
-> [Pretty (SyntaxText' TypeReference)]
forall a b. (a -> b) -> [a] -> [b]
map ((HashQualified Name, TypeReference),
 DisplayObject (Type v a1) (Term v a1))
-> Pretty (SyntaxText' TypeReference)
go ([((HashQualified Name, TypeReference),
   DisplayObject (Type v a1) (Term v a1))]
 -> [Pretty (SyntaxText' TypeReference)])
-> (Map
      (HashQualified Name, TypeReference)
      (DisplayObject (Type v a1) (Term v a1))
    -> [((HashQualified Name, TypeReference),
         DisplayObject (Type v a1) (Term v a1))])
-> Map
     (HashQualified Name, TypeReference)
     (DisplayObject (Type v a1) (Term v a1))
-> [Pretty (SyntaxText' TypeReference)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map
  (HashQualified Name, TypeReference)
  (DisplayObject (Type v a1) (Term v a1))
-> [((HashQualified Name, TypeReference),
     DisplayObject (Type v a1) (Term v a1))]
forall k a. Map k a -> [(k, a)]
Map.toList
      -- sort by name
      (Map
   (HashQualified Name, TypeReference)
   (DisplayObject (Type v a1) (Term v a1))
 -> [Pretty (SyntaxText' TypeReference)])
-> Map
     (HashQualified Name, TypeReference)
     (DisplayObject (Type v a1) (Term v a1))
-> [Pretty (SyntaxText' TypeReference)]
forall a b. (a -> b) -> a -> b
$
        (TypeReference -> (HashQualified Name, TypeReference))
-> Map TypeReference (DisplayObject (Type v a1) (Term v a1))
-> Map
     (HashQualified Name, TypeReference)
     (DisplayObject (Type v a1) (Term v a1))
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys ((TypeReference -> HashQualified Name)
-> (TypeReference, TypeReference)
-> (HashQualified Name, TypeReference)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName PrettyPrintEnv
ppeDecl (Referent -> HashQualified Name)
-> (TypeReference -> Referent)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> Referent
Referent.Ref) ((TypeReference, TypeReference)
 -> (HashQualified Name, TypeReference))
-> (TypeReference -> (TypeReference, TypeReference))
-> TypeReference
-> (HashQualified Name, TypeReference)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> (TypeReference, TypeReference)
forall a. a -> (a, a)
dupe) Map TypeReference (DisplayObject (Type v a1) (Term v a1))
terms
    prettyTypes :: [Pretty (SyntaxText' TypeReference)]
prettyTypes =
      (((HashQualified Name, TypeReference),
  DisplayObject () (Decl v a1))
 -> Pretty (SyntaxText' TypeReference))
-> [((HashQualified Name, TypeReference),
     DisplayObject () (Decl v a1))]
-> [Pretty (SyntaxText' TypeReference)]
forall a b. (a -> b) -> [a] -> [b]
map ((HashQualified Name, TypeReference), DisplayObject () (Decl v a1))
-> Pretty (SyntaxText' TypeReference)
go2 ([((HashQualified Name, TypeReference),
   DisplayObject () (Decl v a1))]
 -> [Pretty (SyntaxText' TypeReference)])
-> (Map
      (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
    -> [((HashQualified Name, TypeReference),
         DisplayObject () (Decl v a1))])
-> Map
     (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
-> [Pretty (SyntaxText' TypeReference)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map
  (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
-> [((HashQualified Name, TypeReference),
     DisplayObject () (Decl v a1))]
forall k a. Map k a -> [(k, a)]
Map.toList (Map
   (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
 -> [Pretty (SyntaxText' TypeReference)])
-> Map
     (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
-> [Pretty (SyntaxText' TypeReference)]
forall a b. (a -> b) -> a -> b
$
        (TypeReference -> (HashQualified Name, TypeReference))
-> Map TypeReference (DisplayObject () (Decl v a1))
-> Map
     (HashQualified Name, TypeReference) (DisplayObject () (Decl v a1))
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys ((TypeReference -> HashQualified Name)
-> (TypeReference, TypeReference)
-> (HashQualified Name, TypeReference)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (PrettyPrintEnv -> TypeReference -> HashQualified Name
PPE.typeName PrettyPrintEnv
ppeDecl) ((TypeReference, TypeReference)
 -> (HashQualified Name, TypeReference))
-> (TypeReference -> (TypeReference, TypeReference))
-> TypeReference
-> (HashQualified Name, TypeReference)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> (TypeReference, TypeReference)
forall a. a -> (a, a)
dupe) Map TypeReference (DisplayObject () (Decl v a1))
types
    go :: ((HashQualified Name, TypeReference),
 DisplayObject (Type v a1) (Term v a1))
-> Pretty (SyntaxText' TypeReference)
go ((HashQualified Name
n, TypeReference
r), DisplayObject (Type v a1) (Term v a1)
dt) =
      case DisplayObject (Type v a1) (Term v a1)
dt of
        MissingObject ShortHash
r -> HashQualified Name
-> ShortHash -> Pretty (SyntaxText' TypeReference)
forall {a}.
Show a =>
HashQualified Name -> a -> Pretty (SyntaxText' TypeReference)
missing HashQualified Name
n ShortHash
r
        BuiltinObject Type v a1
typ ->
          Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.hang
            (Pretty (SyntaxText' TypeReference)
"builtin " Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
n Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
" :")
            (PrettyPrintEnv -> Type v a1 -> Pretty (SyntaxText' TypeReference)
forall v a.
Var v =>
PrettyPrintEnv -> Type v a -> Pretty (SyntaxText' TypeReference)
TypePrinter.prettySyntax (TypeReference -> PrettyPrintEnv
ppeBody TypeReference
r) Type v a1
typ)
        UserObject Term v a1
tm -> PrettyPrintEnv
-> HashQualified Name
-> Term v a1
-> Pretty (SyntaxText' TypeReference)
forall v at ap a.
Var v =>
PrettyPrintEnv
-> HashQualified Name
-> Term2 v at ap v a
-> Pretty (SyntaxText' TypeReference)
TermPrinter.prettyBinding (TypeReference -> PrettyPrintEnv
ppeBody TypeReference
r) HashQualified Name
n Term v a1
tm
    go2 :: ((HashQualified Name, TypeReference), DisplayObject () (Decl v a1))
-> Pretty (SyntaxText' TypeReference)
go2 ((HashQualified Name
n, TypeReference
r), DisplayObject () (Decl v a1)
dt) =
      case DisplayObject () (Decl v a1)
dt of
        MissingObject ShortHash
r -> HashQualified Name
-> ShortHash -> Pretty (SyntaxText' TypeReference)
forall {a}.
Show a =>
HashQualified Name -> a -> Pretty (SyntaxText' TypeReference)
missing HashQualified Name
n ShortHash
r
        BuiltinObject ()
_ -> HashQualified Name -> Pretty (SyntaxText' TypeReference)
builtin HashQualified Name
n
        UserObject Decl v a1
decl -> PrettyPrintEnvDecl
-> TypeReference
-> HashQualified Name
-> Decl v a1
-> Pretty (SyntaxText' TypeReference)
forall v a.
Var v =>
PrettyPrintEnvDecl
-> TypeReference
-> HashQualified Name
-> Decl v a
-> Pretty (SyntaxText' TypeReference)
DeclPrinter.prettyDecl (PrettyPrintEnvDecl -> TypeReference -> PrettyPrintEnvDecl
PPE.declarationPPEDecl PrettyPrintEnvDecl
ppe0 TypeReference
r) TypeReference
r HashQualified Name
n Decl v a1
decl
    builtin :: HashQualified Name -> Pretty (SyntaxText' TypeReference)
builtin HashQualified Name
n = Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty (SyntaxText' TypeReference)
 -> Pretty (SyntaxText' TypeReference))
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' TypeReference)
"--" Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
n Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
" is built-in."
    missing :: HashQualified Name -> a -> Pretty (SyntaxText' TypeReference)
missing HashQualified Name
n a
r =
      Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
        ( Pretty (SyntaxText' TypeReference)
"-- The name "
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified HashQualified Name
n
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
" is assigned to the "
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
"reference "
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> String -> Pretty (SyntaxText' TypeReference)
forall a. IsString a => String -> a
fromString (a -> String
forall a. Show a => a -> String
show a
r String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
",")
            Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
"which is missing from the codebase."
        )
        Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
forall s. IsString s => Pretty s
P.newline
        Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference)
-> Pretty (SyntaxText' TypeReference)
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip Pretty (SyntaxText' TypeReference)
"You might need to repair the codebase manually."

displayRendered :: Maybe FilePath -> Pretty -> IO Pretty
displayRendered :: Maybe String -> Pretty ColorText -> IO (Pretty ColorText)
displayRendered Maybe String
outputLoc Pretty ColorText
pp =
  Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
-> (String -> Pretty ColorText) -> Maybe String -> Pretty ColorText
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Pretty ColorText
pp String -> Pretty ColorText
scratchMessage Maybe String
outputLoc
  where
    scratchMessage :: String -> Pretty ColorText
scratchMessage String
path =
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"☝️" (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"I added this to the top of " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall a. IsString a => String -> a
fromString String
path,
            Pretty ColorText
"",
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 Pretty ColorText
pp
          ]

displayTestResults ::
  Bool -> -- whether to show the tip
  [(HQ.HashQualified Name, [Text])] ->
  [(HQ.HashQualified Name, [Text])] ->
  Pretty
displayTestResults :: Bool
-> [(HashQualified Name, [Text])]
-> [(HashQualified Name, [Text])]
-> Pretty ColorText
displayTestResults Bool
showTip [(HashQualified Name, [Text])]
oks [(HashQualified Name, [Text])]
fails =
  let name :: HashQualified Name -> Pretty ColorText
name = Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (HashQualified Name -> Text)
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Text
HQ.toText
      okMsg :: Pretty ColorText
okMsg =
        if [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
oks
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Int -> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
Int -> f (Pretty ColorText, Pretty ColorText) -> Pretty ColorText
P.numberedColumn2ListFrom Int
0 [(HashQualified Name -> Pretty ColorText
name HashQualified Name
r, [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
P.green (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pretty ColorText
"  ◉ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<>) (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText) -> [Text] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
msgs) | (HashQualified Name
r, [Text]
msgs) <- [(HashQualified Name, [Text])]
oks]
      okSummary :: Pretty ColorText
okSummary =
        if [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
oks
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else Pretty ColorText
"✅ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold (Int -> Pretty ColorText
forall n s. (Show n, Num n, IsString s) => n -> Pretty s
P.num ([Int] -> Int
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ ((HashQualified Name, [Text]) -> Int)
-> [(HashQualified Name, [Text])] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Text] -> Int)
-> ((HashQualified Name, [Text]) -> [Text])
-> (HashQualified Name, [Text])
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name, [Text]) -> [Text]
forall a b. (a, b) -> b
snd) [(HashQualified Name, [Text])]
oks)) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.green Pretty ColorText
" test(s) passing"
      failMsg :: Pretty ColorText
failMsg =
        if [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
fails
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else
            Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
              Int -> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
Int -> f (Pretty ColorText, Pretty ColorText) -> Pretty ColorText
P.numberedColumn2ListFrom
                ([(HashQualified Name, [Text])] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(HashQualified Name, [Text])]
oks)
                [(HashQualified Name -> Pretty ColorText
name HashQualified Name
r, [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
P.red (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pretty ColorText
"  ✗ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<>) (Pretty ColorText -> Pretty ColorText)
-> (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText) -> [Text] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
msgs) | (HashQualified Name
r, [Text]
msgs) <- [(HashQualified Name, [Text])]
fails]
      failSummary :: Pretty ColorText
failSummary =
        if [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
fails
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else Pretty ColorText
"🚫 " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold (Int -> Pretty ColorText
forall n s. (Show n, Num n, IsString s) => n -> Pretty s
P.num ([Int] -> Int
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ ((HashQualified Name, [Text]) -> Int)
-> [(HashQualified Name, [Text])] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Text] -> Int)
-> ((HashQualified Name, [Text]) -> [Text])
-> (HashQualified Name, [Text])
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name, [Text]) -> [Text]
forall a b. (a, b) -> b
snd) [(HashQualified Name, [Text])]
fails)) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
" test(s) failing"
      tipMsg :: Pretty ColorText
tipMsg =
        if Bool -> Bool
not Bool
showTip Bool -> Bool -> Bool
|| ([(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
oks Bool -> Bool -> Bool
&& [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
fails)
          then Pretty ColorText
forall a. Monoid a => a
mempty
          else Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Use " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.blue Pretty ColorText
"view 1" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to view the source of a test."
   in if [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
oks Bool -> Bool -> Bool
&& [(HashQualified Name, [Text])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, [Text])]
fails
        then Pretty ColorText
"😶 No tests available."
        else
          Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            [ Pretty ColorText
okMsg,
              Pretty ColorText
failMsg,
              Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
", " ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText
failSummary, Pretty ColorText
okSummary],
              Pretty ColorText
tipMsg
            ]

unsafePrettyTermResultSig' ::
  (Var v) =>
  PPE.PrettyPrintEnv ->
  SR'.TermResult' v a ->
  Pretty
unsafePrettyTermResultSig' :: forall v a.
Var v =>
PrettyPrintEnv -> TermResult' v a -> Pretty ColorText
unsafePrettyTermResultSig' PrettyPrintEnv
ppe = \case
  SR'.TermResult' HashQualified Name
name (Just Type v a
typ) Referent
r Set (HashQualified Name)
_aliases ->
    [Pretty ColorText] -> Pretty ColorText
forall a. HasCallStack => [a] -> a
head (PrettyPrintEnv
-> [(Referent, HashQualified Name, Type v a)] -> [Pretty ColorText]
forall v a.
Var v =>
PrettyPrintEnv
-> [(Referent, HashQualified Name, Type v a)] -> [Pretty ColorText]
TypePrinter.prettySignaturesCT PrettyPrintEnv
ppe [(Referent
r, HashQualified Name
name, Type v a
typ)])
  TermResult' v a
_ -> String -> Pretty ColorText
forall a. HasCallStack => String -> a
error String
"Don't pass Nothing"

renderNameConflicts :: Int -> Names -> Numbered Pretty
renderNameConflicts :: Int -> Names -> Numbered (Pretty ColorText)
renderNameConflicts Int
hashLen Names
conflictedNames = do
  let conflictedTypeNames :: Map Name [HQ.HashQualified Name]
      conflictedTypeNames :: Map Name [HashQualified Name]
conflictedTypeNames =
        Names
conflictedNames
          Names
-> (Names -> Relation Name TypeReference)
-> Relation Name TypeReference
forall a b. a -> (a -> b) -> b
& Names -> Relation Name TypeReference
Names.types
          Relation Name TypeReference
-> (Relation Name TypeReference -> Map Name (Set TypeReference))
-> Map Name (Set TypeReference)
forall a b. a -> (a -> b) -> b
& Relation Name TypeReference -> Map Name (Set TypeReference)
forall a b. Relation a b -> Map a (Set b)
R.domain
          Map Name (Set TypeReference)
-> (Map Name (Set TypeReference) -> Map Name [HashQualified Name])
-> Map Name [HashQualified Name]
forall a b. a -> (a -> b) -> b
& (Name -> Set TypeReference -> [HashQualified Name])
-> Map Name (Set TypeReference) -> Map Name [HashQualified Name]
forall k a b. (k -> a -> b) -> Map k a -> Map k b
Map.mapWithKey \Name
name -> (TypeReference -> HashQualified Name)
-> [TypeReference] -> [HashQualified Name]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> HashQualified Name -> HashQualified Name
forall n. Int -> HashQualified n -> HashQualified n
HQ.take Int
hashLen (HashQualified Name -> HashQualified Name)
-> (TypeReference -> HashQualified Name)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> ShortHash -> HashQualified Name
forall n. n -> ShortHash -> HashQualified n
HQ.HashQualified Name
name (ShortHash -> HashQualified Name)
-> (TypeReference -> ShortHash)
-> TypeReference
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeReference -> ShortHash
Reference.toShortHash) ([TypeReference] -> [HashQualified Name])
-> (Set TypeReference -> [TypeReference])
-> Set TypeReference
-> [HashQualified Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList
  let conflictedTermNames :: Map Name [HQ.HashQualified Name]
      conflictedTermNames :: Map Name [HashQualified Name]
conflictedTermNames =
        Names
conflictedNames
          Names
-> (Names -> Relation Name Referent) -> Relation Name Referent
forall a b. a -> (a -> b) -> b
& Names -> Relation Name Referent
Names.terms
          Relation Name Referent
-> (Relation Name Referent -> Map Name (Set Referent))
-> Map Name (Set Referent)
forall a b. a -> (a -> b) -> b
& Relation Name Referent -> Map Name (Set Referent)
forall a b. Relation a b -> Map a (Set b)
R.domain
          Map Name (Set Referent)
-> (Map Name (Set Referent) -> Map Name [HashQualified Name])
-> Map Name [HashQualified Name]
forall a b. a -> (a -> b) -> b
& (Name -> Set Referent -> [HashQualified Name])
-> Map Name (Set Referent) -> Map Name [HashQualified Name]
forall k a b. (k -> a -> b) -> Map k a -> Map k b
Map.mapWithKey \Name
name -> (Referent -> HashQualified Name)
-> [Referent] -> [HashQualified Name]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> HashQualified Name -> HashQualified Name
forall n. Int -> HashQualified n -> HashQualified n
HQ.take Int
hashLen (HashQualified Name -> HashQualified Name)
-> (Referent -> HashQualified Name)
-> Referent
-> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> ShortHash -> HashQualified Name
forall n. n -> ShortHash -> HashQualified n
HQ.HashQualified Name
name (ShortHash -> HashQualified Name)
-> (Referent -> ShortHash) -> Referent -> HashQualified Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Referent -> ShortHash
Referent.toShortHash) ([Referent] -> [HashQualified Name])
-> (Set Referent -> [Referent])
-> Set Referent
-> [HashQualified Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set Referent -> [Referent]
forall a. Set a -> [a]
Set.toList
  let allConflictedNames :: [Name]
      allConflictedNames :: [Name]
allConflictedNames = Set Name -> [Name]
forall a. Set a -> [a]
Set.toList (Map Name [HashQualified Name] -> Set Name
forall k a. Map k a -> Set k
Map.keysSet Map Name [HashQualified Name]
conflictedTermNames Set Name -> Set Name -> Set Name
forall a. Semigroup a => a -> a -> a
<> Map Name [HashQualified Name] -> Set Name
forall k a. Map k a -> Set k
Map.keysSet Map Name [HashQualified Name]
conflictedTypeNames)
  Pretty ColorText
prettyConflictedTypes <- Pretty ColorText
-> Map Name [HashQualified Name] -> Numbered (Pretty ColorText)
showConflictedNames Pretty ColorText
"type" Map Name [HashQualified Name]
conflictedTypeNames
  Pretty ColorText
prettyConflictedTerms <- Pretty ColorText
-> Map Name [HashQualified Name] -> Numbered (Pretty ColorText)
showConflictedNames Pretty ColorText
"term" Map Name [HashQualified Name]
conflictedTermNames
  pure $
    Bool -> Pretty ColorText -> Pretty ColorText
forall a. Monoid a => Bool -> a -> a
Monoid.unlessM ([Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Name]
allConflictedNames) (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"❓" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesSpaced ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        [ Pretty ColorText
prettyConflictedTypes,
          Pretty ColorText
prettyConflictedTerms,
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"Use "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample'
                ( if (Bool -> Bool
not (Bool -> Bool)
-> (Map Name [HashQualified Name] -> Bool)
-> Map Name [HashQualified Name]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Name [HashQualified Name] -> Bool
forall a. Map Name a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) Map Name [HashQualified Name]
conflictedTypeNames
                    then InputPattern
IP.renameType
                    else InputPattern
IP.renameTerm
                )
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
makeExample'
                ( if (Bool -> Bool
not (Bool -> Bool)
-> (Map Name [HashQualified Name] -> Bool)
-> Map Name [HashQualified Name]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Name [HashQualified Name] -> Bool
forall a. Map Name a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) Map Name [HashQualified Name]
conflictedTypeNames
                    then InputPattern
IP.deleteType
                    else InputPattern
IP.deleteTerm
                )
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to resolve the conflicts."
        ]
  where
    showConflictedNames :: Pretty -> Map Name [HQ.HashQualified Name] -> Numbered Pretty
    showConflictedNames :: Pretty ColorText
-> Map Name [HashQualified Name] -> Numbered (Pretty ColorText)
showConflictedNames Pretty ColorText
thingKind Map Name [HashQualified Name]
conflictedNames =
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesSpaced ([Pretty ColorText] -> Pretty ColorText)
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> Numbered (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
        [(Name, [HashQualified Name])]
-> ((Name, [HashQualified Name]) -> Numbered (Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for (Map Name [HashQualified Name] -> [(Name, [HashQualified Name])]
forall k a. Map k a -> [(k, a)]
Map.toList Map Name [HashQualified Name]
conflictedNames) \(Name
name, [HashQualified Name]
hashes) -> do
          [Pretty ColorText]
prettyConflicts <- [HashQualified Name]
-> (HashQualified Name -> Numbered (Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [HashQualified Name]
hashes \HashQualified Name
hash -> do
            Int
n <- StructuredArgument -> Numbered Int
addNumberedArg (StructuredArgument -> Numbered Int)
-> StructuredArgument -> Numbered Int
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> StructuredArgument
SA.HashQualified HashQualified Name
hash
            pure $ Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (Pretty ColorText -> Pretty ColorText
P.blue (Pretty ColorText -> Pretty ColorText)
-> (HashQualified Name -> Pretty ColorText)
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty ColorText)
-> HashQualified Name -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ HashQualified Name
hash)
          pure $
            Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
              ( Pretty ColorText
"The "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
thingKind
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" "
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.green (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name)
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" has conflicting definitions:"
              )
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText]
prettyConflicts)

type Numbered = State.State (Int, Seq.Seq StructuredArgument)

addNumberedArg :: StructuredArgument -> Numbered Int
addNumberedArg :: StructuredArgument -> Numbered Int
addNumberedArg StructuredArgument
s = do
  (Int
n, Seq StructuredArgument
args) <- StateT
  (Int, Seq StructuredArgument)
  Identity
  (Int, Seq StructuredArgument)
forall s (m :: * -> *). MonadState s m => m s
State.get
  let !n' :: Int
n' = Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
  (Int, Seq StructuredArgument)
-> StateT (Int, Seq StructuredArgument) Identity ()
forall s (m :: * -> *). MonadState s m => s -> m ()
State.put (Int
n', Seq StructuredArgument
args Seq StructuredArgument
-> StructuredArgument -> Seq StructuredArgument
forall a. Seq a -> a -> Seq a
Seq.|> StructuredArgument
s)
  pure Int
n'

formatNum :: Int -> Pretty
formatNum :: Int -> Pretty ColorText
formatNum Int
n = String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (Int -> String
forall a. Show a => a -> String
show Int
n String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
". ")

runNumbered :: Numbered a -> (a, NumberedArgs)
runNumbered :: forall a. Numbered a -> (a, NumberedArgs)
runNumbered Numbered a
m =
  let (a
a, (Int
_, Seq StructuredArgument
args)) = Numbered a
-> (Int, Seq StructuredArgument)
-> (a, (Int, Seq StructuredArgument))
forall s a. State s a -> s -> (a, s)
State.runState Numbered a
m (Int
0, Seq StructuredArgument
forall a. Monoid a => a
mempty)
   in (a
a, Seq StructuredArgument -> NumberedArgs
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Foldable.toList Seq StructuredArgument
args)

handleTodoOutput :: TodoOutput -> Numbered Pretty
handleTodoOutput :: TodoOutput -> Numbered (Pretty ColorText)
handleTodoOutput TodoOutput
todo
  | TodoOutput -> Bool
todoOutputIsEmpty TodoOutput
todo = Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
"You have no pending todo items. Good work! ✅"
  | Bool
otherwise = do
      Pretty ColorText
prettyDependentsOfTodo <- do
        if Set TermReferenceId -> Bool
forall a. Set a -> Bool
Set.null TodoOutput
todo.dependentsOfTodo
          then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          else do
            [Pretty ColorText]
terms <-
              [TermReferenceId]
-> (TermReferenceId -> Numbered (Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for (Set TermReferenceId -> [TermReferenceId]
forall a. Set a -> [a]
Set.toList TodoOutput
todo.dependentsOfTodo) \TermReferenceId
term -> do
                Int
n <- StructuredArgument -> Numbered Int
addNumberedArg (HashQualified Name -> StructuredArgument
SA.HashQualified (ShortHash -> HashQualified Name
forall n. ShortHash -> HashQualified n
HQ.HashOnly (TermReferenceId -> ShortHash
Reference.idToShortHash TermReferenceId
term)))
                let name :: Pretty ColorText
name =
                      TermReferenceId
term
                        TermReferenceId -> (TermReferenceId -> Referent) -> Referent
forall a b. a -> (a -> b) -> b
& TermReferenceId -> Referent
Referent.fromTermReferenceId
                        Referent -> (Referent -> HashQualified Name) -> HashQualified Name
forall a b. a -> (a -> b) -> b
& PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName TodoOutput
todo.ppe.suffixifiedPPE
                        HashQualified Name
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> Pretty (SyntaxText' TypeReference)
forall a b. a -> (a -> b) -> b
& HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified
                        Pretty (SyntaxText' TypeReference)
-> (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> Pretty ColorText
forall a b. a -> (a -> b) -> b
& Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor
                pure (Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
name)
            pure $
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"These terms call `todo`:"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText]
terms)

      Pretty ColorText
prettyDirectTermDependenciesWithoutNames <- do
        if Set TypeReference -> Bool
forall a. Set a -> Bool
Set.null TodoOutput
todo.directDependenciesWithoutNames.terms
          then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          else do
            [Pretty ColorText]
terms <-
              [TypeReference]
-> (TypeReference -> Numbered (Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for (Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList TodoOutput
todo.directDependenciesWithoutNames.terms) \TypeReference
term -> do
                Int
n <- StructuredArgument -> Numbered Int
addNumberedArg (HashQualified Name -> StructuredArgument
SA.HashQualified (ShortHash -> HashQualified Name
forall n. ShortHash -> HashQualified n
HQ.HashOnly (TypeReference -> ShortHash
Reference.toShortHash TypeReference
term)))
                pure (Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference TodoOutput
todo.hashLen TypeReference
term))
            pure $
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"These terms do not have any names in the current namespace:"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText]
terms)

      Pretty ColorText
prettyDirectTypeDependenciesWithoutNames <- do
        if Set TypeReference -> Bool
forall a. Set a -> Bool
Set.null TodoOutput
todo.directDependenciesWithoutNames.types
          then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          else do
            [Pretty ColorText]
types <-
              [TypeReference]
-> (TypeReference -> Numbered (Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for (Set TypeReference -> [TypeReference]
forall a. Set a -> [a]
Set.toList TodoOutput
todo.directDependenciesWithoutNames.types) \TypeReference
typ -> do
                Int
n <- StructuredArgument -> Numbered Int
addNumberedArg (HashQualified Name -> StructuredArgument
SA.HashQualified (ShortHash -> HashQualified Name
forall n. ShortHash -> HashQualified n
HQ.HashOnly (TypeReference -> ShortHash
Reference.toShortHash TypeReference
typ)))
                pure (Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference TodoOutput
todo.hashLen TypeReference
typ))
            pure $
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"These types do not have any names in the current namespace:"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText]
types)

      Pretty ColorText
prettyConflicts <-
        if TodoOutput
todo.nameConflicts Names -> Names -> Bool
forall a. Eq a => a -> a -> Bool
== Names
forall a. Monoid a => a
mempty
          then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          else Int -> Names -> Numbered (Pretty ColorText)
renderNameConflicts TodoOutput
todo.hashLen TodoOutput
todo.nameConflicts

      let prettyDefnsInLib :: Pretty ColorText
prettyDefnsInLib =
            if TodoOutput
todo.defnsInLib
              then
                Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                  -- Note [DefnsInLibMessage] If you change this, also change the other similar one
                  Pretty ColorText
"There's a type or term at the top level of the `lib` namespace, where I only expect to find"
                    Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"subnamespaces representing library dependencies. Please move or remove it."
              else Pretty ColorText
forall a. Monoid a => a
mempty

      Pretty ColorText
prettyConstructorAliases <-
        let -- We want to filter out constructor aliases whose types are part of a "nested decl alias" problem, because
            -- otherwise we'd essentially be reporting those issues twice.
            --
            -- That is, if we have two nested aliases like
            --
            --   Foo = #XYZ
            --   Foo.Bar = #XYZ#0
            --
            --   Foo.inner.Alias = #XYZ
            --   Foo.inner.Alias.Constructor = #XYZ#0
            --
            -- then we'd prefer to say "oh no Foo and Foo.inner.Alias are aliases" but *not* additionally say "oh no
            -- Foo.Bar and Foo.inner.Alias.Constructor are aliases".
            notNestedDeclAlias :: (Name, Name, Name) -> Bool
notNestedDeclAlias (Name
typeName, Name
_, Name
_) =
              ((Name, Name) -> Bool -> Bool) -> Bool -> [(Name, Name)] -> Bool
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
                (\(Name
short, Name
long) Bool
acc -> Name
typeName Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
/= Name
short Bool -> Bool -> Bool
&& Name
typeName Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
/= Name
long Bool -> Bool -> Bool
&& Bool
acc)
                Bool
True
                TodoOutput
todo.incoherentDeclReasons.nestedDeclAliases
         in case ((Name, Name, Name) -> Bool)
-> [(Name, Name, Name)] -> [(Name, Name, Name)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Name, Name, Name) -> Bool
notNestedDeclAlias TodoOutput
todo.incoherentDeclReasons.constructorAliases of
              [] -> Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
              [(Name, Name, Name)]
aliases -> do
                [(Name, Pretty ColorText, Pretty ColorText)]
things <-
                  [(Name, Name, Name)]
-> ((Name, Name, Name)
    -> StateT
         (Int, Seq StructuredArgument)
         Identity
         (Name, Pretty ColorText, Pretty ColorText))
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Name, Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [(Name, Name, Name)]
aliases \(Name
typeName, Name
conName1, Name
conName2) -> do
                    Int
n1 <- StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
conName1)
                    Int
n2 <- StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
conName2)
                    pure (Name
typeName, Int -> Pretty ColorText
formatNum Int
n1 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName1, Int -> Pretty ColorText
formatNum Int
n2 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
conName2)
                pure $
                  [(Name, Pretty ColorText, Pretty ColorText)]
things
                    [(Name, Pretty ColorText, Pretty ColorText)]
-> ([(Name, Pretty ColorText, Pretty ColorText)]
    -> [Pretty ColorText])
-> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& ((Name, Pretty ColorText, Pretty ColorText) -> Pretty ColorText)
-> [(Name, Pretty ColorText, Pretty ColorText)]
-> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map
                      ( \(Name
typeName, Pretty ColorText
prettyCon1, Pretty ColorText
prettyCon2) ->
                          -- Note [ConstructorAliasMessage] If you change this, also change the other similar ones
                          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText
"The type" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typeName Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"has a constructor with multiple names.")
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
prettyCon1, Pretty ColorText
prettyCon2])
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"Please delete all but one name for each constructor."
                      )
                    [Pretty ColorText]
-> ([Pretty ColorText] -> Pretty ColorText) -> Pretty ColorText
forall a b. a -> (a -> b) -> b
& Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n"

      Pretty ColorText
prettyMissingConstructorNames <-
        case [Name] -> Maybe (NonEmpty Name)
forall a. [a] -> Maybe (NonEmpty a)
NEList.nonEmpty TodoOutput
todo.incoherentDeclReasons.missingConstructorNames of
          Maybe (NonEmpty Name)
Nothing -> Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          Just NonEmpty Name
types0 -> do
            NonEmpty (Int, Name)
stuff <-
              NonEmpty Name
-> (Name
    -> StateT (Int, Seq StructuredArgument) Identity (Int, Name))
-> StateT
     (Int, Seq StructuredArgument) Identity (NonEmpty (Int, Name))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for NonEmpty Name
types0 \Name
typ -> do
                Int
n <- StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
typ)
                pure (Int
n, Name
typ)
            -- Note [MissingConstructorNameMessage] If you change this, also change the other similar ones
            pure $
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                Pretty ColorText
"These types have some constructors with missing names."
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (NonEmpty (Pretty ColorText) -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (((Int, Name) -> Pretty ColorText)
-> NonEmpty (Int, Name) -> NonEmpty (Pretty ColorText)
forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
n, Name
typ) -> Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
typ) NonEmpty (Int, Name)
stuff))
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                  ( Pretty ColorText
"You can use"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample
                        InputPattern
IP.view
                        [ let firstNum :: Int
firstNum = (Int, Name) -> Int
forall a b. (a, b) -> a
fst (NonEmpty (Int, Name) -> (Int, Name)
forall a. NonEmpty a -> a
NEList.head NonEmpty (Int, Name)
stuff)
                              lastNum :: Int
lastNum = (Int, Name) -> Int
forall a b. (a, b) -> a
fst (NonEmpty (Int, Name) -> (Int, Name)
forall a. NonEmpty a -> a
NEList.last NonEmpty (Int, Name)
stuff)
                           in if Int
firstNum Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
lastNum
                                then String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (Int -> String
forall a. Show a => a -> String
show Int
firstNum)
                                else String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (Int -> String
forall a. Show a => a -> String
show Int
firstNum) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"-" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall s. IsString s => String -> Pretty s
P.string (Int -> String
forall a. Show a => a -> String
show Int
lastNum)
                        ]
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"and"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.aliasTerm [Pretty ColorText
"<hash>", Pretty ColorText
"<TypeName>.<ConstructorName>"]
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to give names to each unnamed constructor."
                  )

      Pretty ColorText
prettyNestedDeclAliases <-
        case TodoOutput
todo.incoherentDeclReasons.nestedDeclAliases of
          [] -> Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          [(Name, Name)]
aliases0 -> do
            [(Pretty ColorText, Pretty ColorText)]
aliases1 <-
              [(Name, Name)]
-> ((Name, Name)
    -> StateT
         (Int, Seq StructuredArgument)
         Identity
         (Pretty ColorText, Pretty ColorText))
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [(Name, Name)]
aliases0 \(Name
short, Name
long) -> do
                Int
n1 <- StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
short)
                Int
n2 <- StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
long)
                pure (Int -> Pretty ColorText
formatNum Int
n1 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
short, Int -> Pretty ColorText
formatNum Int
n2 Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
long)
            -- Note [NestedDeclAliasMessage] If you change this, also change the other similar ones
            pure $
              [(Pretty ColorText, Pretty ColorText)]
aliases1
                [(Pretty ColorText, Pretty ColorText)]
-> ([(Pretty ColorText, Pretty ColorText)] -> [Pretty ColorText])
-> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& ((Pretty ColorText, Pretty ColorText) -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map
                  ( \(Pretty ColorText
short, Pretty ColorText
long) ->
                      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                        ( Pretty ColorText
"These types are aliases, but one is nested under the other. Please separate them or delete"
                            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"one copy."
                        )
                        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 ([Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
short, Pretty ColorText
long])
                  )
                [Pretty ColorText]
-> ([Pretty ColorText] -> Pretty ColorText) -> Pretty ColorText
forall a b. a -> (a -> b) -> b
& Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n"

      Pretty ColorText
prettyStrayConstructors <-
        case TodoOutput
todo.incoherentDeclReasons.strayConstructors of
          [] -> Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          [(TermReferenceId, Name)]
constructors -> do
            [Int]
nums <-
              [(TermReferenceId, Name)]
-> ((TermReferenceId, Name) -> Numbered Int)
-> StateT (Int, Seq StructuredArgument) Identity [Int]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [(TermReferenceId, Name)]
constructors \(TermReferenceId
_typeRef, Name
constructor) -> do
                StructuredArgument -> Numbered Int
addNumberedArg (Name -> StructuredArgument
SA.Name Name
constructor)
            -- Note [StrayConstructorMessage] If you change this, also change the other similar ones
            pure $
              Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"These constructors are not nested beneath their corresponding type names:"
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN
                  Width
2
                  ( [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                      ( (Int -> (TermReferenceId, Name) -> Pretty ColorText)
-> [Int] -> [(TermReferenceId, Name)] -> [Pretty ColorText]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith
                          (\Int
n (TermReferenceId
_typeRef, Name
constructor) -> Int -> Pretty ColorText
formatNum Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
constructor)
                          [Int]
nums
                          [(TermReferenceId, Name)]
constructors
                      )
                  )
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
forall s. IsString s => Pretty s
P.newline
                Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                  ( Pretty ColorText
"For each one, please either use"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.moveAll
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to move if, or if it's an extra copy, you can simply"
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> Pretty ColorText
IP.makeExample' InputPattern
IP.delete
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"it."
                  )

      (Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty)
        [ Pretty ColorText
prettyDependentsOfTodo,
          Pretty ColorText
prettyDirectTermDependenciesWithoutNames,
          Pretty ColorText
prettyDirectTypeDependenciesWithoutNames,
          Pretty ColorText
prettyConflicts,
          Pretty ColorText
prettyDefnsInLib,
          Pretty ColorText
prettyConstructorAliases,
          Pretty ColorText
prettyMissingConstructorNames,
          Pretty ColorText
prettyNestedDeclAliases,
          Pretty ColorText
prettyStrayConstructors
        ]

listOfDefinitions ::
  (Var v) => Input.FindScope -> PPE.PrettyPrintEnv -> E.ListDetailed -> [SR'.SearchResult' v a] -> IO Pretty
listOfDefinitions :: forall v a.
Var v =>
FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> IO (Pretty ColorText)
listOfDefinitions FindScope
fscope PrettyPrintEnv
ppe Bool
detailed [SearchResult' v a]
results =
  Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> Pretty ColorText
forall v a.
Var v =>
FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> Pretty ColorText
listOfDefinitions' FindScope
fscope PrettyPrintEnv
ppe Bool
detailed [SearchResult' v a]
results

listOfNames :: Int -> [(Reference, [HQ'.HashQualified Name])] -> [(Referent, [HQ'.HashQualified Name])] -> IO Pretty
listOfNames :: Int
-> [(TypeReference, [HashQualified Name])]
-> [(Referent, [HashQualified Name])]
-> IO (Pretty ColorText)
listOfNames Int
len [(TypeReference, [HashQualified Name])]
types [(Referent, [HashQualified Name])]
terms = do
  if [(TypeReference, [HashQualified Name])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(TypeReference, [HashQualified Name])]
types Bool -> Bool -> Bool
&& [(Referent, [HashQualified Name])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Referent, [HashQualified Name])]
terms
    then
      Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> IO (Pretty ColorText))
-> Pretty ColorText -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
        Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap Pretty ColorText
"I couldn't find anything by that name."
          ]
    else
      Pretty ColorText -> IO (Pretty ColorText)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> IO (Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> IO (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> IO (Pretty ColorText))
-> [Pretty ColorText] -> IO (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
        [ [(TypeReference, [HashQualified Name])] -> Pretty ColorText
formatTypes [(TypeReference, [HashQualified Name])]
types,
          [(Referent, [HashQualified Name])] -> Pretty ColorText
formatTerms [(Referent, [HashQualified Name])]
terms
        ]
  where
    formatTerms :: [(Referent, [HashQualified Name])] -> Pretty ColorText
formatTerms [(Referent, [HashQualified Name])]
tms =
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [(Referent, [HashQualified Name])]
-> Pretty ColorText -> Pretty ColorText
forall (f :: * -> *) a.
Foldable f =>
f a -> Pretty ColorText -> Pretty ColorText
P.plural [(Referent, [HashQualified Name])]
tms (Pretty ColorText -> Pretty ColorText
P.blue Pretty ColorText
"Term") Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
List.intersperse Pretty ColorText
"" ((Referent, [HashQualified Name]) -> Pretty ColorText
go ((Referent, [HashQualified Name]) -> Pretty ColorText)
-> [(Referent, [HashQualified Name])] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Referent, [HashQualified Name])]
tms)
      where
        go :: (Referent, [HashQualified Name]) -> Pretty ColorText
go (Referent
ref, [HashQualified Name]
hqs) =
          [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2
            [ (Pretty ColorText
"Hash:", Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Int -> Referent -> Pretty (SyntaxText' TypeReference)
prettyReferent Int
len Referent
ref)),
              ( Pretty ColorText
"Names: ",
                Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.spaced ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    Pretty ColorText -> Pretty ColorText
P.bold (Pretty ColorText -> Pretty ColorText)
-> (HashQualified Name -> Pretty ColorText)
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HashQualified Name -> HashQualified Name -> Ordering)
-> [HashQualified Name] -> [HashQualified Name]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy HashQualified Name -> HashQualified Name -> Ordering
forall n. Alphabetical n => n -> n -> Ordering
Name.compareAlphabetical [HashQualified Name]
hqs
              )
            ]
    formatTypes :: [(TypeReference, [HashQualified Name])] -> Pretty ColorText
formatTypes [(TypeReference, [HashQualified Name])]
types =
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [(TypeReference, [HashQualified Name])]
-> Pretty ColorText -> Pretty ColorText
forall (f :: * -> *) a.
Foldable f =>
f a -> Pretty ColorText -> Pretty ColorText
P.plural [(TypeReference, [HashQualified Name])]
types (Pretty ColorText -> Pretty ColorText
P.blue Pretty ColorText
"Type") Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
List.intersperse Pretty ColorText
"" ((TypeReference, [HashQualified Name]) -> Pretty ColorText
go ((TypeReference, [HashQualified Name]) -> Pretty ColorText)
-> [(TypeReference, [HashQualified Name])] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(TypeReference, [HashQualified Name])]
types)
      where
        go :: (TypeReference, [HashQualified Name]) -> Pretty ColorText
go (TypeReference
ref, [HashQualified Name]
hqs) =
          [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2
            [ (Pretty ColorText
"Hash:", Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Int -> TypeReference -> Pretty (SyntaxText' TypeReference)
prettyReference Int
len TypeReference
ref)),
              ( Pretty ColorText
"Names:",
                Pretty ColorText -> Pretty ColorText
forall s. Pretty s -> Pretty s
P.group (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                  [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.spaced ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    Pretty ColorText -> Pretty ColorText
P.bold (Pretty ColorText -> Pretty ColorText)
-> (HashQualified Name -> Pretty ColorText)
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HashQualified Name -> HashQualified Name -> Ordering)
-> [HashQualified Name] -> [HashQualified Name]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy HashQualified Name -> HashQualified Name -> Ordering
forall n. Alphabetical n => n -> n -> Ordering
Name.compareAlphabetical [HashQualified Name]
hqs
              )
            ]

data ShowNumbers = ShowNumbers | HideNumbers

-- | `ppe` is just for rendering type signatures
--   `oldPath, newPath :: Path.Absolute` are just for producing fully-qualified
--                                       numbered args
showDiffNamespace ::
  forall v.
  (Var v) =>
  ShowNumbers ->
  PPE.PrettyPrintEnv ->
  Input.AbsBranchId ->
  Input.AbsBranchId ->
  OBD.BranchDiffOutput v Ann ->
  (Pretty, NumberedArgs)
showDiffNamespace :: forall v.
Var v =>
ShowNumbers
-> PrettyPrintEnv
-> AbsBranchId
-> AbsBranchId
-> BranchDiffOutput v Ann
-> (Pretty ColorText, NumberedArgs)
showDiffNamespace ShowNumbers
_ PrettyPrintEnv
_ AbsBranchId
_ AbsBranchId
_ BranchDiffOutput v Ann
diffOutput
  | BranchDiffOutput v Ann -> Bool
forall v a. BranchDiffOutput v a -> Bool
OBD.isEmpty BranchDiffOutput v Ann
diffOutput =
      (Pretty ColorText
"The namespaces are identical.", NumberedArgs
forall a. Monoid a => a
mempty)
showDiffNamespace ShowNumbers
sn PrettyPrintEnv
ppe AbsBranchId
oldPath AbsBranchId
newPath OBD.BranchDiffOutput {[PatchDisplay]
[RemovedTypeDisplay v Ann]
[RemovedTermDisplay v Ann]
[RenameTypeDisplay v Ann]
[RenameTermDisplay v Ann]
[UpdateTypeDisplay v Ann]
[UpdateTermDisplay v Ann]
updatedTypes :: [UpdateTypeDisplay v Ann]
updatedTerms :: [UpdateTermDisplay v Ann]
newTypeConflicts :: [UpdateTypeDisplay v Ann]
newTermConflicts :: [UpdateTermDisplay v Ann]
resolvedTypeConflicts :: [UpdateTypeDisplay v Ann]
resolvedTermConflicts :: [UpdateTermDisplay v Ann]
updatedPatches :: [PatchDisplay]
addedTypes :: [RemovedTypeDisplay v Ann]
addedTerms :: [RemovedTermDisplay v Ann]
addedPatches :: [PatchDisplay]
removedTypes :: [RemovedTypeDisplay v Ann]
removedTerms :: [RemovedTermDisplay v Ann]
removedPatches :: [PatchDisplay]
renamedTypes :: [RenameTypeDisplay v Ann]
renamedTerms :: [RenameTermDisplay v Ann]
$sel:updatedTypes:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTypeDisplay v a]
$sel:updatedTerms:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTermDisplay v a]
$sel:newTypeConflicts:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTypeDisplay v a]
$sel:newTermConflicts:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTermDisplay v a]
$sel:resolvedTypeConflicts:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTypeDisplay v a]
$sel:resolvedTermConflicts:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [UpdateTermDisplay v a]
$sel:updatedPatches:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [PatchDisplay]
$sel:addedTypes:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [AddedTypeDisplay v a]
$sel:addedTerms:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [AddedTermDisplay v a]
$sel:addedPatches:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [PatchDisplay]
$sel:removedTypes:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [AddedTypeDisplay v a]
$sel:removedTerms:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [AddedTermDisplay v a]
$sel:removedPatches:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [PatchDisplay]
$sel:renamedTypes:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [RenameTypeDisplay v a]
$sel:renamedTerms:BranchDiffOutput :: forall v a. BranchDiffOutput v a -> [RenameTermDisplay v a]
..} =
  (Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" [Pretty ColorText]
p, Seq StructuredArgument -> NumberedArgs
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Seq StructuredArgument
args)
  where
    ([Pretty ColorText]
p, (Int
menuSize, Seq StructuredArgument
args)) =
      (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> (Int, Seq StructuredArgument)
-> ([Pretty ColorText], (Int, Seq StructuredArgument))
forall s a. State s a -> s -> (a, s)
`State.runState` (Int
0 :: Int, Seq StructuredArgument
forall a. Seq a
Seq.empty)) (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
 -> ([Pretty ColorText], (Int, Seq StructuredArgument)))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> ([Pretty ColorText], (Int, Seq StructuredArgument))
forall a b. (a -> b) -> a -> b
$
        [Numbered (Pretty ColorText)]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence
          [ if (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTypeDisplay v Ann] -> Bool)
-> [UpdateTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTypeDisplay v Ann]
newTypeConflicts
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTermDisplay v Ann] -> Bool)
-> [UpdateTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTermDisplay v Ann]
newTermConflicts
              then do
                [Pretty ColorText]
prettyUpdatedTypes :: [Pretty] <- (UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTypeDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTypeDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateType [UpdateTypeDisplay v Ann]
newTypeConflicts
                [Pretty ColorText]
prettyUpdatedTerms :: [Pretty] <- (UpdateTermDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTermDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTermDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTermDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateTerm [UpdateTermDisplay v Ann]
newTermConflicts
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
"New name conflicts:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
prettyUpdatedTypes [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText]
prettyUpdatedTerms
                    ]
              else Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty,
            if (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTypeDisplay v Ann] -> Bool)
-> [UpdateTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTypeDisplay v Ann]
resolvedTypeConflicts
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTermDisplay v Ann] -> Bool)
-> [UpdateTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTermDisplay v Ann]
resolvedTermConflicts
              then do
                [Pretty ColorText]
prettyUpdatedTypes :: [Pretty] <- (UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTypeDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTypeDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateType [UpdateTypeDisplay v Ann]
resolvedTypeConflicts
                [Pretty ColorText]
prettyUpdatedTerms :: [Pretty] <- (UpdateTermDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTermDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTermDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTermDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateTerm [UpdateTermDisplay v Ann]
resolvedTermConflicts
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Resolved name conflicts:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
prettyUpdatedTypes [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText]
prettyUpdatedTerms
                    ]
              else Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty,
            if (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTypeDisplay v Ann] -> Bool)
-> [UpdateTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTypeDisplay v Ann]
updatedTypes
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([UpdateTermDisplay v Ann] -> Bool)
-> [UpdateTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UpdateTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [UpdateTermDisplay v Ann]
updatedTerms
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([PatchDisplay] -> Bool) -> [PatchDisplay] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PatchDisplay] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [PatchDisplay]
updatedPatches
              then do
                [Pretty ColorText]
prettyUpdatedTypes :: [Pretty] <- (UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTypeDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTypeDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTypeDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateType [UpdateTypeDisplay v Ann]
updatedTypes
                [Pretty ColorText]
prettyUpdatedTerms :: [Pretty] <- (UpdateTermDisplay v Ann -> Numbered (Pretty ColorText))
-> [UpdateTermDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse UpdateTermDisplay v Ann -> Numbered (Pretty ColorText)
forall a. UpdateTermDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateTerm [UpdateTermDisplay v Ann]
updatedTerms
                [Pretty ColorText]
prettyUpdatedPatches :: [Pretty] <- (PatchDisplay -> Numbered (Pretty ColorText))
-> [PatchDisplay]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId -> PatchDisplay -> Numbered (Pretty ColorText)
prettySummarizePatch AbsBranchId
newPath) [PatchDisplay]
updatedPatches
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Updates:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNonEmptyN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
prettyUpdatedTypes [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText]
prettyUpdatedTerms,
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNonEmptyN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
prettyUpdatedPatches
                    ]
              else Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty,
            if (Bool -> Bool
not (Bool -> Bool)
-> ([RemovedTypeDisplay v Ann] -> Bool)
-> [RemovedTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RemovedTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RemovedTypeDisplay v Ann]
addedTypes
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([RemovedTermDisplay v Ann] -> Bool)
-> [RemovedTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RemovedTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RemovedTermDisplay v Ann]
addedTerms
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([PatchDisplay] -> Bool) -> [PatchDisplay] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PatchDisplay] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [PatchDisplay]
addedPatches
              then do
                Pretty ColorText
prettyAddedTypes :: Pretty <- [RemovedTypeDisplay v Ann] -> Numbered (Pretty ColorText)
forall a. [AddedTypeDisplay v a] -> Numbered (Pretty ColorText)
prettyAddTypes [RemovedTypeDisplay v Ann]
addedTypes
                Pretty ColorText
prettyAddedTerms :: Pretty <- [RemovedTermDisplay v Ann] -> Numbered (Pretty ColorText)
forall a. [AddedTermDisplay v a] -> Numbered (Pretty ColorText)
prettyAddTerms [RemovedTermDisplay v Ann]
addedTerms
                [Pretty ColorText]
prettyAddedPatches :: [Pretty] <- (PatchDisplay -> Numbered (Pretty ColorText))
-> [PatchDisplay]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId -> PatchDisplay -> Numbered (Pretty ColorText)
prettySummarizePatch AbsBranchId
newPath) [PatchDisplay]
addedPatches
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Added definitions:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNonEmptyN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty [Pretty ColorText
prettyAddedTypes, Pretty ColorText
prettyAddedTerms],
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentNonEmptyN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText]
prettyAddedPatches
                    ]
              else Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty,
            if (Bool -> Bool
not (Bool -> Bool)
-> ([RemovedTypeDisplay v Ann] -> Bool)
-> [RemovedTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RemovedTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RemovedTypeDisplay v Ann]
removedTypes
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([RemovedTermDisplay v Ann] -> Bool)
-> [RemovedTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RemovedTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RemovedTermDisplay v Ann]
removedTerms
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([PatchDisplay] -> Bool) -> [PatchDisplay] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PatchDisplay] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [PatchDisplay]
removedPatches
              then do
                Pretty ColorText
prettyRemovedTypes :: Pretty <- [RemovedTypeDisplay v Ann] -> Numbered (Pretty ColorText)
forall a. [AddedTypeDisplay v a] -> Numbered (Pretty ColorText)
prettyRemoveTypes [RemovedTypeDisplay v Ann]
removedTypes
                Pretty ColorText
prettyRemovedTerms :: Pretty <- [RemovedTermDisplay v Ann] -> Numbered (Pretty ColorText)
forall a. [AddedTermDisplay v a] -> Numbered (Pretty ColorText)
prettyRemoveTerms [RemovedTermDisplay v Ann]
removedTerms
                [Pretty ColorText]
prettyRemovedPatches :: [Pretty] <- (PatchDisplay -> Numbered (Pretty ColorText))
-> [PatchDisplay]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId -> PatchDisplay -> Numbered (Pretty ColorText)
prettyNamePatch AbsBranchId
oldPath) [PatchDisplay]
removedPatches
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Removed definitions:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty
                          [ Pretty ColorText
prettyRemovedTypes,
                            Pretty ColorText
prettyRemovedTerms,
                            [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty [Pretty ColorText]
prettyRemovedPatches
                          ]
                    ]
              else Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty,
            if (Bool -> Bool
not (Bool -> Bool)
-> ([RenameTypeDisplay v Ann] -> Bool)
-> [RenameTypeDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RenameTypeDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RenameTypeDisplay v Ann]
renamedTypes
              Bool -> Bool -> Bool
|| (Bool -> Bool
not (Bool -> Bool)
-> ([RenameTermDisplay v Ann] -> Bool)
-> [RenameTermDisplay v Ann]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RenameTermDisplay v Ann] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) [RenameTermDisplay v Ann]
renamedTerms
              then do
                [Pretty ColorText]
results <- [RenameTypeDisplay v Ann]
-> [RenameTermDisplay v Ann]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall a.
[RenameTypeDisplay v a]
-> [RenameTermDisplay v a]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
prettyRenameGroups [RenameTypeDisplay v Ann]
renamedTypes [RenameTermDisplay v Ann]
renamedTerms
                pure $
                  Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
                    Pretty ColorText
"\n\n"
                    [ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Name changes:",
                      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
results
                    ]
              else -- todo: change separator to just '\n' here if all the results are 1 to 1
                Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty
          ]

    {- new implementation
      23. X  ┐  =>  (added)   24. X'
      25. X2 ┘      (removed) 26. X2
    -}
    prettyRenameGroups ::
      [OBD.RenameTypeDisplay v a] ->
      [OBD.RenameTermDisplay v a] ->
      Numbered [Pretty]
    prettyRenameGroups :: forall a.
[RenameTypeDisplay v a]
-> [RenameTermDisplay v a]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
prettyRenameGroups [(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
types [(Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name))]
terms =
      [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
(<>)
        ([Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText])
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     ([Pretty ColorText] -> [Pretty ColorText])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name)),
  Int)
 -> Numbered (Pretty ColorText))
-> [((TypeReference, Maybe (DeclOrBuiltin v a),
      Set (HashQualified Name), Set (HashQualified Name)),
     Int)]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse
          (((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
  Set (HashQualified Name)),
 Int)
-> Numbered (Pretty ColorText)
forall b.
((Referent, b, Set (HashQualified Name), Set (HashQualified Name)),
 Int)
-> Numbered (Pretty ColorText)
prettyGroup (((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
   Set (HashQualified Name)),
  Int)
 -> Numbered (Pretty ColorText))
-> (((TypeReference, Maybe (DeclOrBuiltin v a),
      Set (HashQualified Name), Set (HashQualified Name)),
     Int)
    -> ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
         Set (HashQualified Name)),
        Int))
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name)),
    Int)
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ASetter
  ((TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name)),
   Int)
  ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
    Set (HashQualified Name)),
   Int)
  TypeReference
  Referent
-> (TypeReference -> Referent)
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name)),
    Int)
-> ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
     Set (HashQualified Name)),
    Int)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (((TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))
 -> Identity
      (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
       Set (HashQualified Name)))
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name)),
    Int)
-> Identity
     ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
       Set (HashQualified Name)),
      Int)
forall s t a b. Field1 s t a b => Lens s t a b
Lens
  ((TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name)),
   Int)
  ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
    Set (HashQualified Name)),
   Int)
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
   Set (HashQualified Name))
_1 (((TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  -> Identity
       (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
        Set (HashQualified Name)))
 -> ((TypeReference, Maybe (DeclOrBuiltin v a),
      Set (HashQualified Name), Set (HashQualified Name)),
     Int)
 -> Identity
      ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
        Set (HashQualified Name)),
       Int))
-> ((TypeReference -> Identity Referent)
    -> (TypeReference, Maybe (DeclOrBuiltin v a),
        Set (HashQualified Name), Set (HashQualified Name))
    -> Identity
         (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
          Set (HashQualified Name)))
-> ASetter
     ((TypeReference, Maybe (DeclOrBuiltin v a),
       Set (HashQualified Name), Set (HashQualified Name)),
      Int)
     ((Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
       Set (HashQualified Name)),
      Int)
     TypeReference
     Referent
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReference -> Identity Referent)
-> (TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name))
-> Identity
     (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
      Set (HashQualified Name))
forall s t a b. Field1 s t a b => Lens s t a b
Lens
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (Referent, Maybe (DeclOrBuiltin v a), Set (HashQualified Name),
   Set (HashQualified Name))
  TypeReference
  Referent
_1) TypeReference -> Referent
Referent.Ref))
          ([(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
types [(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
-> [Int]
-> [((TypeReference, Maybe (DeclOrBuiltin v a),
      Set (HashQualified Name), Set (HashQualified Name)),
     Int)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [Int
0 ..])
        StateT
  (Int, Seq StructuredArgument)
  Identity
  ([Pretty ColorText] -> [Pretty ColorText])
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall a b.
StateT (Int, Seq StructuredArgument) Identity (a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (((Referent, Maybe (Type v a), Set (HashQualified Name),
   Set (HashQualified Name)),
  Int)
 -> Numbered (Pretty ColorText))
-> [((Referent, Maybe (Type v a), Set (HashQualified Name),
      Set (HashQualified Name)),
     Int)]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name)),
 Int)
-> Numbered (Pretty ColorText)
forall b.
((Referent, b, Set (HashQualified Name), Set (HashQualified Name)),
 Int)
-> Numbered (Pretty ColorText)
prettyGroup ([(Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name))]
terms [(Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name))]
-> [Int]
-> [((Referent, Maybe (Type v a), Set (HashQualified Name),
      Set (HashQualified Name)),
     Int)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [[(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
-> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
types ..])
      where
        Width
leftNamePad :: P.Width =
          (Width -> Width -> Width) -> [Width] -> Width
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Width -> Width -> Width
forall a. Ord a => a -> a -> a
max ([Width] -> Width) -> [Width] -> Width
forall a b. (a -> b) -> a -> b
$
            ((Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name))
 -> Width)
-> [(Referent, Maybe (Type v a), Set (HashQualified Name),
     Set (HashQualified Name))]
-> [Width]
forall a b. (a -> b) -> [a] -> [b]
map
              ((Width -> Width -> Width) -> [Width] -> Width
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Width -> Width -> Width
forall a. Ord a => a -> a -> a
max ([Width] -> Width)
-> ((Referent, Maybe (Type v a), Set (HashQualified Name),
     Set (HashQualified Name))
    -> [Width])
-> (Referent, Maybe (Type v a), Set (HashQualified Name),
    Set (HashQualified Name))
-> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name -> Width) -> [HashQualified Name] -> [Width]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Width
P.Width (Int -> Width)
-> (HashQualified Name -> Int) -> HashQualified Name -> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Text) -> HashQualified Name -> Int
HQ'.nameLength Name -> Text
Name.toText) ([HashQualified Name] -> [Width])
-> ((Referent, Maybe (Type v a), Set (HashQualified Name),
     Set (HashQualified Name))
    -> [HashQualified Name])
-> (Referent, Maybe (Type v a), Set (HashQualified Name),
    Set (HashQualified Name))
-> [Width]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set (HashQualified Name) -> [HashQualified Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set (HashQualified Name) -> [HashQualified Name])
-> ((Referent, Maybe (Type v a), Set (HashQualified Name),
     Set (HashQualified Name))
    -> Set (HashQualified Name))
-> (Referent, Maybe (Type v a), Set (HashQualified Name),
    Set (HashQualified Name))
-> [HashQualified Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Set (HashQualified Name))
  (Referent, Maybe (Type v a), Set (HashQualified Name),
   Set (HashQualified Name))
  (Set (HashQualified Name))
-> (Referent, Maybe (Type v a), Set (HashQualified Name),
    Set (HashQualified Name))
-> Set (HashQualified Name)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Set (HashQualified Name))
  (Referent, Maybe (Type v a), Set (HashQualified Name),
   Set (HashQualified Name))
  (Set (HashQualified Name))
forall s t a b. Field3 s t a b => Lens s t a b
Lens
  (Referent, Maybe (Type v a), Set (HashQualified Name),
   Set (HashQualified Name))
  (Referent, Maybe (Type v a), Set (HashQualified Name),
   Set (HashQualified Name))
  (Set (HashQualified Name))
  (Set (HashQualified Name))
_3)
              [(Referent, Maybe (Type v a), Set (HashQualified Name),
  Set (HashQualified Name))]
terms
              [Width] -> [Width] -> [Width]
forall a. Semigroup a => a -> a -> a
<> ((TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))
 -> Width)
-> [(TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name))]
-> [Width]
forall a b. (a -> b) -> [a] -> [b]
map
                ((Width -> Width -> Width) -> [Width] -> Width
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Width -> Width -> Width
forall a. Ord a => a -> a -> a
max ([Width] -> Width)
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name))
    -> [Width])
-> (TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name))
-> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name -> Width) -> [HashQualified Name] -> [Width]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Width
P.Width (Int -> Width)
-> (HashQualified Name -> Int) -> HashQualified Name -> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Text) -> HashQualified Name -> Int
HQ'.nameLength Name -> Text
Name.toText) ([HashQualified Name] -> [Width])
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name))
    -> [HashQualified Name])
-> (TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name))
-> [Width]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set (HashQualified Name) -> [HashQualified Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set (HashQualified Name) -> [HashQualified Name])
-> ((TypeReference, Maybe (DeclOrBuiltin v a),
     Set (HashQualified Name), Set (HashQualified Name))
    -> Set (HashQualified Name))
-> (TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name))
-> [HashQualified Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Set (HashQualified Name))
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (Set (HashQualified Name))
-> (TypeReference, Maybe (DeclOrBuiltin v a),
    Set (HashQualified Name), Set (HashQualified Name))
-> Set (HashQualified Name)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Set (HashQualified Name))
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (Set (HashQualified Name))
forall s t a b. Field3 s t a b => Lens s t a b
Lens
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (TypeReference, Maybe (DeclOrBuiltin v a),
   Set (HashQualified Name), Set (HashQualified Name))
  (Set (HashQualified Name))
  (Set (HashQualified Name))
_3)
                [(TypeReference, Maybe (DeclOrBuiltin v a),
  Set (HashQualified Name), Set (HashQualified Name))]
types
        prettyGroup ::
          ( (Referent, b, Set (HQ'.HashQualified Name), Set (HQ'.HashQualified Name)),
            Int
          ) ->
          Numbered Pretty
        prettyGroup :: forall b.
((Referent, b, Set (HashQualified Name), Set (HashQualified Name)),
 Int)
-> Numbered (Pretty ColorText)
prettyGroup ((Referent
r, b
_, Set (HashQualified Name)
olds, Set (HashQualified Name)
news), Int
i) =
          let -- [ "peach  ┐"
              -- , "peach' ┘"]
              [Numbered (Pretty ColorText)]
olds' :: [Numbered Pretty] =
                let olds0 :: [HashQualified Name]
olds0 = (HashQualified Name -> HashQualified Name -> Ordering)
-> [HashQualified Name] -> [HashQualified Name]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy HashQualified Name -> HashQualified Name -> Ordering
forall n. Alphabetical n => n -> n -> Ordering
Name.compareAlphabetical (Set (HashQualified Name) -> [HashQualified Name]
forall a. Set a -> [a]
Set.toList Set (HashQualified Name)
olds)
                 in ((HashQualified Name, Pretty ColorText)
 -> Numbered (Pretty ColorText))
-> [(HashQualified Name, Pretty ColorText)]
-> [Numbered (Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
map (\(HashQualified Name
oldhq, Pretty ColorText
oldp) -> AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
oldPath HashQualified Name
oldhq Referent
r Numbered (Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Numbered (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (\Pretty ColorText
n -> Pretty ColorText
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
oldp))
                      ([(HashQualified Name, Pretty ColorText)]
 -> [Numbered (Pretty ColorText)])
-> ([HashQualified Name]
    -> [(HashQualified Name, Pretty ColorText)])
-> [HashQualified Name]
-> [Numbered (Pretty ColorText)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [HashQualified Name]
-> [Pretty ColorText] -> [(HashQualified Name, Pretty ColorText)]
forall a b. [a] -> [b] -> [(a, b)]
zip [HashQualified Name]
olds0
                      ([Pretty ColorText] -> [(HashQualified Name, Pretty ColorText)])
-> ([HashQualified Name] -> [Pretty ColorText])
-> [HashQualified Name]
-> [(HashQualified Name, Pretty ColorText)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxRight
                      ([Pretty ColorText] -> [Pretty ColorText])
-> ([HashQualified Name] -> [Pretty ColorText])
-> [HashQualified Name]
-> [Pretty ColorText]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map (Width -> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Width -> Pretty s -> Pretty s
P.rightPad Width
leftNamePad (Pretty ColorText -> Pretty ColorText)
-> (HashQualified Name -> Pretty ColorText)
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty ColorText
phq')
                      ([HashQualified Name] -> [Numbered (Pretty ColorText)])
-> [HashQualified Name] -> [Numbered (Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$ [HashQualified Name]
olds0

              added' :: [HashQualified Name]
added' = Set (HashQualified Name) -> [HashQualified Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set (HashQualified Name) -> [HashQualified Name])
-> Set (HashQualified Name) -> [HashQualified Name]
forall a b. (a -> b) -> a -> b
$ Set (HashQualified Name)
-> Set (HashQualified Name) -> Set (HashQualified Name)
forall a. Ord a => Set a -> Set a -> Set a
Set.difference Set (HashQualified Name)
news Set (HashQualified Name)
olds
              removed' :: [HashQualified Name]
removed' = Set (HashQualified Name) -> [HashQualified Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set (HashQualified Name) -> [HashQualified Name])
-> Set (HashQualified Name) -> [HashQualified Name]
forall a b. (a -> b) -> a -> b
$ Set (HashQualified Name)
-> Set (HashQualified Name) -> Set (HashQualified Name)
forall a. Ord a => Set a -> Set a -> Set a
Set.difference Set (HashQualified Name)
olds Set (HashQualified Name)
news
              -- [ "(added)   24. X'"
              -- , "(removed) 26. X2"
              -- ]

              [Numbered (Pretty ColorText)]
news' :: [Numbered Pretty] =
                (HashQualified Name -> Numbered (Pretty ColorText))
-> [HashQualified Name] -> [Numbered (Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
map (Pretty ColorText
-> HashQualified Name -> Numbered (Pretty ColorText)
number Pretty ColorText
addedLabel) [HashQualified Name]
added' [Numbered (Pretty ColorText)]
-> [Numbered (Pretty ColorText)] -> [Numbered (Pretty ColorText)]
forall a. [a] -> [a] -> [a]
++ (HashQualified Name -> Numbered (Pretty ColorText))
-> [HashQualified Name] -> [Numbered (Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
map (Pretty ColorText
-> HashQualified Name -> Numbered (Pretty ColorText)
number Pretty ColorText
removedLabel) [HashQualified Name]
removed'
                where
                  addedLabel :: Pretty ColorText
addedLabel = Pretty ColorText
"(added)"
                  removedLabel :: Pretty ColorText
removedLabel = Pretty ColorText
"(removed)"
                  number :: Pretty ColorText
-> HashQualified Name -> Numbered (Pretty ColorText)
number Pretty ColorText
label HashQualified Name
name =
                    AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
name Referent
r
                      Numbered (Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Numbered (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (\Pretty ColorText
num -> Pretty ColorText
num Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> HashQualified Name -> Pretty ColorText
phq' HashQualified Name
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
label)

              buildTable :: [Numbered Pretty] -> [Numbered Pretty] -> Numbered Pretty
              buildTable :: [Numbered (Pretty ColorText)]
-> [Numbered (Pretty ColorText)] -> Numbered (Pretty ColorText)
buildTable [Numbered (Pretty ColorText)]
lefts [Numbered (Pretty ColorText)]
rights =
                let hlefts :: [Numbered (Pretty ColorText)]
hlefts =
                      if Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
                        then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Original") Numbered (Pretty ColorText)
-> [Numbered (Pretty ColorText)] -> [Numbered (Pretty ColorText)]
forall a. a -> [a] -> [a]
: [Numbered (Pretty ColorText)]
lefts
                        else [Numbered (Pretty ColorText)]
lefts
                    hrights :: [Numbered (Pretty ColorText)]
hrights = if Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 then Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Changes") Numbered (Pretty ColorText)
-> [Numbered (Pretty ColorText)] -> [Numbered (Pretty ColorText)]
forall a. a -> [a] -> [a]
: [Numbered (Pretty ColorText)]
rights else [Numbered (Pretty ColorText)]
rights
                 in forall (m :: * -> *) s.
(ListLike s Char, IsString s, Monad m) =>
Pretty s -> [m (Pretty s)] -> [m (Pretty s)] -> m (Pretty s)
P.column2UnzippedM @Numbered Pretty ColorText
forall a. Monoid a => a
mempty [Numbered (Pretty ColorText)]
hlefts [Numbered (Pretty ColorText)]
hrights
           in [Numbered (Pretty ColorText)]
-> [Numbered (Pretty ColorText)] -> Numbered (Pretty ColorText)
buildTable [Numbered (Pretty ColorText)]
olds' [Numbered (Pretty ColorText)]
news'

    prettyUpdateType :: OBD.UpdateTypeDisplay v a -> Numbered Pretty
    {-
       1. ability Foo#pqr x y
          2. - AllRightsReserved : License
          3. + MIT               : License
       4. ability Foo#abc
          5. - apiDocs : License
          6. + MIT     : License
    -}
    prettyUpdateType :: forall a. UpdateTypeDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateType (OBD.UpdateTypeDisplay Maybe [SimpleTypeDisplay v a]
Nothing [TypeDisplay v a]
mdUps) =
      [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TypeDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTypeLine AbsBranchId
newPath) [TypeDisplay v a]
mdUps
    {-
        1. ┌ ability Foo#pqr x y
        2. └ ability Foo#xyz a b
           ⧩
        4. ┌ ability Foo#abc
           │  5. - apiDocs : Doc
           │  6. + MIT     : License
        7. └ ability Foo#def
              8. - apiDocs : Doc
              9. + MIT     : License

        1. ┌ foo#abc : Nat -> Nat -> Poop
        2. └ foo#xyz : Nat
           ↓
        4. foo	 : Poop
             5. + foo.docs : Doc
    -}
    prettyUpdateType (OBD.UpdateTypeDisplay (Just [SimpleTypeDisplay v a]
olds) [TypeDisplay v a]
news) =
      do
        [(Pretty ColorText, Pretty ColorText)]
olds <- (TypeDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TypeDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTypeLine AbsBranchId
oldPath) [HashQualified Name
-> TypeReference -> Maybe (DeclOrBuiltin v a) -> TypeDisplay v a
forall v a.
HashQualified Name
-> TypeReference -> Maybe (DeclOrBuiltin v a) -> TypeDisplay v a
OBD.TypeDisplay HashQualified Name
name TypeReference
r Maybe (DeclOrBuiltin v a)
decl | (HashQualified Name
name, TypeReference
r, Maybe (DeclOrBuiltin v a)
decl) <- [SimpleTypeDisplay v a]
olds]
        [(Pretty ColorText, Pretty ColorText)]
news <- (TypeDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TypeDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTypeLine AbsBranchId
newPath) [TypeDisplay v a]
news
        let ([Pretty ColorText]
oldnums, [Pretty ColorText]
olddatas) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
olds
        let ([Pretty ColorText]
newnums, [Pretty ColorText]
newdatas) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
news
        Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)]
 -> Numbered (Pretty ColorText))
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
          [Pretty ColorText]
-> [Pretty ColorText] -> [(Pretty ColorText, Pretty ColorText)]
forall a b. [a] -> [b] -> [(a, b)]
zip
            ([Pretty ColorText]
oldnums [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText
""] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText]
newnums)
            ([Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft [Pretty ColorText]
olddatas [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText
downArrow] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft [Pretty ColorText]
newdatas)

    {-
    13. ┌ability Yyz
    14. └ability copies.Yyz
    -}
    prettyAddTypes :: forall a. [OBD.AddedTypeDisplay v a] -> Numbered Pretty
    prettyAddTypes :: forall a. [AddedTypeDisplay v a] -> Numbered (Pretty ColorText)
prettyAddTypes = ([Pretty ColorText] -> Pretty ColorText)
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
 -> Numbered (Pretty ColorText))
-> ([AddedTypeDisplay v a]
    -> StateT
         (Int, Seq StructuredArgument) Identity [Pretty ColorText])
-> [AddedTypeDisplay v a]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AddedTypeDisplay v a -> Numbered (Pretty ColorText))
-> [AddedTypeDisplay v a]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse AddedTypeDisplay v a -> Numbered (Pretty ColorText)
prettyGroup
      where
        prettyGroup :: OBD.AddedTypeDisplay v a -> Numbered Pretty
        prettyGroup :: AddedTypeDisplay v a -> Numbered (Pretty ColorText)
prettyGroup ([HashQualified Name]
hqs, TypeReference
r, Maybe (DeclOrBuiltin v a)
odecl) = do
          [(Pretty ColorText, Pretty ColorText)]
pairs <- (HashQualified Name
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [HashQualified Name]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (TypeReference
-> Maybe (DeclOrBuiltin v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
prettyLine TypeReference
r Maybe (DeclOrBuiltin v a)
odecl) [HashQualified Name]
hqs
          let ([Pretty ColorText]
nums, [Pretty ColorText]
decls) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
pairs
          let boxLeft :: [Pretty ColorText] -> [Pretty ColorText]
boxLeft = case [HashQualified Name]
hqs of
                HashQualified Name
_ : HashQualified Name
_ : [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft
                [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> a
id
          Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)]
 -> Numbered (Pretty ColorText))
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
-> [Pretty ColorText] -> [(Pretty ColorText, Pretty ColorText)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Pretty ColorText]
nums ([Pretty ColorText] -> [Pretty ColorText]
boxLeft [Pretty ColorText]
decls)
        prettyLine :: Reference -> Maybe (DD.DeclOrBuiltin v a) -> HQ'.HashQualified Name -> Numbered (Pretty, Pretty)
        prettyLine :: TypeReference
-> Maybe (DeclOrBuiltin v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
prettyLine TypeReference
r Maybe (DeclOrBuiltin v a)
odecl HashQualified Name
hq = do
          Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
hq (TypeReference -> Referent
Referent.Ref TypeReference
r)
          (Pretty ColorText, Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Pretty ColorText, Pretty ColorText)
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> (Pretty ColorText -> (Pretty ColorText, Pretty ColorText))
-> Pretty ColorText
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pretty ColorText
n,) (Pretty ColorText
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> Pretty ColorText
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
forall {v} {a}.
Var v =>
HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
prettyDecl HashQualified Name
hq Maybe (DeclOrBuiltin v a)
odecl

    prettyAddTerms :: forall a. [OBD.AddedTermDisplay v a] -> Numbered Pretty
    prettyAddTerms :: forall a. [AddedTermDisplay v a] -> Numbered (Pretty ColorText)
prettyAddTerms = ([[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
 -> Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s, Pretty s)] -> Pretty s
P.column3 ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
 -> Pretty ColorText)
-> ([[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
    -> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. Monoid a => [a] -> a
mconcat) (StateT
   (Int, Seq StructuredArgument)
   Identity
   [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
 -> Numbered (Pretty ColorText))
-> ([AddedTermDisplay v a]
    -> StateT
         (Int, Seq StructuredArgument)
         Identity
         [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]])
-> [AddedTermDisplay v a]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AddedTermDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [AddedTermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse AddedTermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
prettyGroup ([AddedTermDisplay v a]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]])
-> ([AddedTermDisplay v a] -> [AddedTermDisplay v a])
-> [AddedTermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AddedTermDisplay v a] -> [AddedTermDisplay v a]
reorderTerms
      where
        reorderTerms :: [AddedTermDisplay v a] -> [AddedTermDisplay v a]
reorderTerms = (AddedTermDisplay v a -> Bool)
-> [AddedTermDisplay v a] -> [AddedTermDisplay v a]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (Bool -> Bool
not (Bool -> Bool)
-> (AddedTermDisplay v a -> Bool) -> AddedTermDisplay v a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Referent -> Bool
forall r. Referent' r -> Bool
Referent.isConstructor (Referent -> Bool)
-> (AddedTermDisplay v a -> Referent)
-> AddedTermDisplay v a
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting Referent (AddedTermDisplay v a) Referent
-> AddedTermDisplay v a -> Referent
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Referent (AddedTermDisplay v a) Referent
forall s t a b. Field2 s t a b => Lens s t a b
Lens
  (AddedTermDisplay v a) (AddedTermDisplay v a) Referent Referent
_2)
        prettyGroup :: OBD.AddedTermDisplay v a -> Numbered [(Pretty, Pretty, Pretty)]
        prettyGroup :: AddedTermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
prettyGroup ([HashQualified Name]
hqs, Referent
r, Maybe (Type v a)
otype) = do
          [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
pairs <- (HashQualified Name
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> [HashQualified Name]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Referent
-> Maybe (Type v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine Referent
r Maybe (Type v a)
otype) [HashQualified Name]
hqs
          let ([Pretty ColorText]
nums, [Pretty ColorText]
names, [Pretty ColorText]
decls) = [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText], [Pretty ColorText])
forall a b c. [(a, b, c)] -> ([a], [b], [c])
unzip3 [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
pairs
              boxLeft :: [Pretty ColorText] -> [Pretty ColorText]
boxLeft =
                case [HashQualified Name]
hqs of
                  HashQualified Name
_ : HashQualified Name
_ : [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft
                  [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> a
id
          [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
-> [Pretty ColorText]
-> [Pretty ColorText]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 [Pretty ColorText]
nums ([Pretty ColorText] -> [Pretty ColorText]
boxLeft [Pretty ColorText]
names) [Pretty ColorText]
decls
        prettyLine ::
          Referent ->
          Maybe (Type v a) ->
          HQ'.HashQualified Name ->
          Numbered (Pretty, Pretty, Pretty)
        prettyLine :: Referent
-> Maybe (Type v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine Referent
r Maybe (Type v a)
otype HashQualified Name
hq = do
          Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
hq Referent
r
          (Pretty ColorText, Pretty ColorText, Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Pretty ColorText, Pretty ColorText, Pretty ColorText)
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> (Pretty ColorText
    -> (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> Pretty ColorText
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pretty ColorText
n,HashQualified Name -> Pretty ColorText
phq' HashQualified Name
hq,) (Pretty ColorText
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> Pretty ColorText
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
": " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Maybe (Type v a) -> Pretty ColorText
forall a. Maybe (Type v a) -> Pretty ColorText
prettyType Maybe (Type v a)
otype

    prettySummarizePatch, prettyNamePatch :: Input.AbsBranchId -> OBD.PatchDisplay -> Numbered Pretty
    --  12. patch p (added 3 updates, deleted 1)
    prettySummarizePatch :: AbsBranchId -> PatchDisplay -> Numbered (Pretty ColorText)
prettySummarizePatch AbsBranchId
prefix (Name
name, PatchDiff
patchDiff) = do
      Pretty ColorText
n <- AbsBranchId -> Name -> Numbered (Pretty ColorText)
numPatch AbsBranchId
prefix Name
name
      let addCount :: Int
addCount =
            (Relation TypeReference TermEdit -> Int
forall a b. Relation a b -> Int
R.size (Relation TypeReference TermEdit -> Int)
-> (PatchDiff -> Relation TypeReference TermEdit)
-> PatchDiff
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Relation TypeReference TermEdit)
  PatchDiff
  (Relation TypeReference TermEdit)
-> PatchDiff -> Relation TypeReference TermEdit
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Relation TypeReference TermEdit)
  PatchDiff
  (Relation TypeReference TermEdit)
Lens' PatchDiff (Relation TypeReference TermEdit)
Patch.addedTermEdits) PatchDiff
patchDiff
              Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Relation TypeReference TypeEdit -> Int
forall a b. Relation a b -> Int
R.size (Relation TypeReference TypeEdit -> Int)
-> (PatchDiff -> Relation TypeReference TypeEdit)
-> PatchDiff
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Relation TypeReference TypeEdit)
  PatchDiff
  (Relation TypeReference TypeEdit)
-> PatchDiff -> Relation TypeReference TypeEdit
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Relation TypeReference TypeEdit)
  PatchDiff
  (Relation TypeReference TypeEdit)
Lens' PatchDiff (Relation TypeReference TypeEdit)
Patch.addedTypeEdits) PatchDiff
patchDiff
          delCount :: Int
delCount =
            (Relation TypeReference TermEdit -> Int
forall a b. Relation a b -> Int
R.size (Relation TypeReference TermEdit -> Int)
-> (PatchDiff -> Relation TypeReference TermEdit)
-> PatchDiff
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Relation TypeReference TermEdit)
  PatchDiff
  (Relation TypeReference TermEdit)
-> PatchDiff -> Relation TypeReference TermEdit
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Relation TypeReference TermEdit)
  PatchDiff
  (Relation TypeReference TermEdit)
Lens' PatchDiff (Relation TypeReference TermEdit)
Patch.removedTermEdits) PatchDiff
patchDiff
              Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Relation TypeReference TypeEdit -> Int
forall a b. Relation a b -> Int
R.size (Relation TypeReference TypeEdit -> Int)
-> (PatchDiff -> Relation TypeReference TypeEdit)
-> PatchDiff
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (Relation TypeReference TypeEdit)
  PatchDiff
  (Relation TypeReference TypeEdit)
-> PatchDiff -> Relation TypeReference TypeEdit
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Relation TypeReference TypeEdit)
  PatchDiff
  (Relation TypeReference TypeEdit)
Lens' PatchDiff (Relation TypeReference TypeEdit)
Patch.removedTypeEdits) PatchDiff
patchDiff
          messages :: [Pretty ColorText]
messages =
            (if Int
addCount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 then [Pretty ColorText
"added " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
addCount] else [])
              [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. [a] -> [a] -> [a]
++ (if Int
delCount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 then [Pretty ColorText
"deleted " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
addCount] else [])
          message :: Pretty ColorText
message = case [Pretty ColorText]
messages of
            [] -> Pretty ColorText
forall a. Monoid a => a
mempty
            Pretty ColorText
x : [Pretty ColorText]
ys -> Pretty ColorText
" (" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.commas (Pretty ColorText
x Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" updates" Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: [Pretty ColorText]
ys) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
")"
      pure $ Pretty ColorText
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
" patch " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
message
    --          18. patch q
    prettyNamePatch :: AbsBranchId -> PatchDisplay -> Numbered (Pretty ColorText)
prettyNamePatch AbsBranchId
prefix (Name
name, PatchDiff
_patchDiff) = do
      Pretty ColorText
n <- AbsBranchId -> Name -> Numbered (Pretty ColorText)
numPatch AbsBranchId
prefix Name
name
      pure $ Pretty ColorText
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
" patch " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
name

    {-
     Removes:

       10. ┌ oldn'busted : Nat -> Nat -> Poop
       11. └ oldn'busted'
       12.  ability BadType
       13.  patch defunctThingy
    -}
    prettyRemoveTypes :: forall a. [OBD.RemovedTypeDisplay v a] -> Numbered Pretty
    prettyRemoveTypes :: forall a. [AddedTypeDisplay v a] -> Numbered (Pretty ColorText)
prettyRemoveTypes = ([Pretty ColorText] -> Pretty ColorText)
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
 -> Numbered (Pretty ColorText))
-> ([RemovedTypeDisplay v a]
    -> StateT
         (Int, Seq StructuredArgument) Identity [Pretty ColorText])
-> [RemovedTypeDisplay v a]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RemovedTypeDisplay v a -> Numbered (Pretty ColorText))
-> [RemovedTypeDisplay v a]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse RemovedTypeDisplay v a -> Numbered (Pretty ColorText)
prettyGroup
      where
        prettyGroup :: OBD.RemovedTypeDisplay v a -> Numbered Pretty
        prettyGroup :: RemovedTypeDisplay v a -> Numbered (Pretty ColorText)
prettyGroup ([HashQualified Name]
hqs, TypeReference
r, Maybe (DeclOrBuiltin v a)
odecl) = do
          [(Pretty ColorText, Pretty ColorText)]
lines <- (HashQualified Name
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [HashQualified Name]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (TypeReference
-> Maybe (DeclOrBuiltin v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
prettyLine TypeReference
r Maybe (DeclOrBuiltin v a)
odecl) [HashQualified Name]
hqs
          let ([Pretty ColorText]
nums, [Pretty ColorText]
decls) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
lines
              boxLeft :: [Pretty ColorText] -> [Pretty ColorText]
boxLeft = case [HashQualified Name]
hqs of HashQualified Name
_ : HashQualified Name
_ : [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft; [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> a
id
          Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)]
 -> Numbered (Pretty ColorText))
-> [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
-> [Pretty ColorText] -> [(Pretty ColorText, Pretty ColorText)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Pretty ColorText]
nums ([Pretty ColorText] -> [Pretty ColorText]
boxLeft [Pretty ColorText]
decls)
        prettyLine :: Reference -> Maybe (DD.DeclOrBuiltin v a) -> HQ'.HashQualified Name -> Numbered (Pretty, Pretty)
        prettyLine :: TypeReference
-> Maybe (DeclOrBuiltin v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
prettyLine TypeReference
r Maybe (DeclOrBuiltin v a)
odecl HashQualified Name
hq = do
          Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
hq (TypeReference -> Referent
Referent.Ref TypeReference
r)
          pure (Pretty ColorText
n, HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
forall {v} {a}.
Var v =>
HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
prettyDecl HashQualified Name
hq Maybe (DeclOrBuiltin v a)
odecl)

    prettyRemoveTerms :: forall a. [OBD.RemovedTermDisplay v a] -> Numbered Pretty
    prettyRemoveTerms :: forall a. [AddedTermDisplay v a] -> Numbered (Pretty ColorText)
prettyRemoveTerms = ([[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
 -> Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s, Pretty s)] -> Pretty s
P.column3 ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
 -> Pretty ColorText)
-> ([[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
    -> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. Monoid a => [a] -> a
mconcat) (StateT
   (Int, Seq StructuredArgument)
   Identity
   [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
 -> Numbered (Pretty ColorText))
-> ([RemovedTermDisplay v a]
    -> StateT
         (Int, Seq StructuredArgument)
         Identity
         [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]])
-> [RemovedTermDisplay v a]
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RemovedTermDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [RemovedTermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse RemovedTermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
prettyGroup ([RemovedTermDisplay v a]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]])
-> ([RemovedTermDisplay v a] -> [RemovedTermDisplay v a])
-> [RemovedTermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [[(Pretty ColorText, Pretty ColorText, Pretty ColorText)]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RemovedTermDisplay v a] -> [RemovedTermDisplay v a]
reorderTerms
      where
        reorderTerms :: [RemovedTermDisplay v a] -> [RemovedTermDisplay v a]
reorderTerms = (RemovedTermDisplay v a -> Bool)
-> [RemovedTermDisplay v a] -> [RemovedTermDisplay v a]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (Bool -> Bool
not (Bool -> Bool)
-> (RemovedTermDisplay v a -> Bool)
-> RemovedTermDisplay v a
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Referent -> Bool
forall r. Referent' r -> Bool
Referent.isConstructor (Referent -> Bool)
-> (RemovedTermDisplay v a -> Referent)
-> RemovedTermDisplay v a
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting Referent (RemovedTermDisplay v a) Referent
-> RemovedTermDisplay v a -> Referent
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Referent (RemovedTermDisplay v a) Referent
forall s t a b. Field2 s t a b => Lens s t a b
Lens
  (RemovedTermDisplay v a) (RemovedTermDisplay v a) Referent Referent
_2)
        prettyGroup :: OBD.RemovedTermDisplay v a -> Numbered [(Pretty, Pretty, Pretty)]
        prettyGroup :: RemovedTermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
prettyGroup ([], Referent
r, Maybe (Type v a)
_) =
          String
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. HasCallStack => String -> a
error (String
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> String
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$ String
"trying to remove " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Referent -> String
forall a. Show a => a -> String
show Referent
r String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" without any names."
        prettyGroup (HashQualified Name
hq1 : [HashQualified Name]
hqs, Referent
r, Maybe (Type v a)
otype) = do
          (Pretty ColorText, Pretty ColorText, Pretty ColorText)
line1 <- Referent
-> Maybe (Type v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine1 Referent
r Maybe (Type v a)
otype HashQualified Name
hq1
          [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
lines <- (HashQualified Name
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText, Pretty ColorText))
-> [HashQualified Name]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Referent
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine Referent
r) [HashQualified Name]
hqs
          let ([Pretty ColorText]
nums, [Pretty ColorText]
names, [Pretty ColorText]
decls) = [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText], [Pretty ColorText])
forall a b c. [(a, b, c)] -> ([a], [b], [c])
unzip3 ((Pretty ColorText, Pretty ColorText, Pretty ColorText)
line1 (Pretty ColorText, Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
: [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
lines)
              boxLeft :: [Pretty ColorText] -> [Pretty ColorText]
boxLeft = case [HashQualified Name]
hqs of HashQualified Name
_ : [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft; [HashQualified Name]
_ -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> a
id
          [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText, Pretty ColorText)])
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText]
-> [Pretty ColorText]
-> [Pretty ColorText]
-> [(Pretty ColorText, Pretty ColorText, Pretty ColorText)]
forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 [Pretty ColorText]
nums ([Pretty ColorText] -> [Pretty ColorText]
boxLeft [Pretty ColorText]
names) [Pretty ColorText]
decls
        prettyLine1 :: Referent
-> Maybe (Type v a)
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine1 Referent
r Maybe (Type v a)
otype HashQualified Name
hq = do
          Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
hq Referent
r
          pure (Pretty ColorText
n, HashQualified Name -> Pretty ColorText
phq' HashQualified Name
hq, Pretty ColorText
": " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Maybe (Type v a) -> Pretty ColorText
forall a. Maybe (Type v a) -> Pretty ColorText
prettyType Maybe (Type v a)
otype)
        prettyLine :: Referent
-> HashQualified Name
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText, Pretty ColorText)
prettyLine Referent
r HashQualified Name
hq = do
          Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
newPath HashQualified Name
hq Referent
r
          pure (Pretty ColorText
n, HashQualified Name -> Pretty ColorText
phq' HashQualified Name
hq, Pretty ColorText
forall a. Monoid a => a
mempty)

    downArrow :: Pretty ColorText
downArrow = Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"↓"
    mdTypeLine :: Input.AbsBranchId -> OBD.TypeDisplay v a -> Numbered (Pretty, Pretty)
    mdTypeLine :: forall a.
AbsBranchId
-> TypeDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTypeLine AbsBranchId
p (OBD.TypeDisplay HashQualified Name
hq TypeReference
r Maybe (DeclOrBuiltin v a)
odecl) = do
      Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
p HashQualified Name
hq (TypeReference -> Referent
Referent.Ref TypeReference
r)
      ([Pretty ColorText] -> (Pretty ColorText, Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Pretty ColorText
n,) (Pretty ColorText -> (Pretty ColorText, Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> (Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty) (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> ([Numbered (Pretty ColorText)]
    -> StateT
         (Int, Seq StructuredArgument) Identity [Pretty ColorText])
-> [Numbered (Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Numbered (Pretty ColorText)]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ([Numbered (Pretty ColorText)]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [Numbered (Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a b. (a -> b) -> a -> b
$
        [ Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> Pretty ColorText -> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
forall {v} {a}.
Var v =>
HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
prettyDecl HashQualified Name
hq Maybe (DeclOrBuiltin v a)
odecl
        ]

    -- + 2. MIT               : License
    -- - 3. AllRightsReserved : License
    mdTermLine ::
      Input.AbsBranchId ->
      P.Width ->
      OBD.TermDisplay v a ->
      Numbered (Pretty, Pretty)
    mdTermLine :: forall a.
AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTermLine AbsBranchId
p Width
namesWidth (OBD.TermDisplay HashQualified Name
hq Referent
r Maybe (Type v a)
otype) = do
      Pretty ColorText
n <- AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
p HashQualified Name
hq Referent
r
      ([Pretty ColorText] -> (Pretty ColorText, Pretty ColorText))
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Pretty ColorText
n,) (Pretty ColorText -> (Pretty ColorText, Pretty ColorText))
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> (Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.linesNonEmpty)
        (StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> ([Numbered (Pretty ColorText)]
    -> StateT
         (Int, Seq StructuredArgument) Identity [Pretty ColorText])
-> [Numbered (Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Numbered (Pretty ColorText)]
-> StateT (Int, Seq StructuredArgument) Identity [Pretty ColorText]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence
        ([Numbered (Pretty ColorText)]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [Numbered (Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ [ Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pretty ColorText -> Numbered (Pretty ColorText))
-> Pretty ColorText -> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ Width -> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Width -> Pretty s -> Pretty s
P.rightPad Width
namesWidth (HashQualified Name -> Pretty ColorText
phq' HashQualified Name
hq) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" : " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Maybe (Type v a) -> Pretty ColorText
forall a. Maybe (Type v a) -> Pretty ColorText
prettyType Maybe (Type v a)
otype
          ]

    prettyUpdateTerm :: OBD.UpdateTermDisplay v a -> Numbered Pretty
    prettyUpdateTerm :: forall a. UpdateTermDisplay v a -> Numbered (Pretty ColorText)
prettyUpdateTerm (OBD.UpdateTermDisplay Maybe [(HashQualified Name, Referent, Maybe (Type v a))]
Nothing [TermDisplay v a]
newTerms) =
      if [TermDisplay v a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TermDisplay v a]
newTerms
        then String -> Numbered (Pretty ColorText)
forall a. HasCallStack => String -> a
error String
"Super invalid UpdateTermDisplay"
        else ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 (StateT
   (Int, Seq StructuredArgument)
   Identity
   [(Pretty ColorText, Pretty ColorText)]
 -> Numbered (Pretty ColorText))
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ (TermDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTermLine AbsBranchId
newPath Width
namesWidth) [TermDisplay v a]
newTerms
      where
        namesWidth :: Width
namesWidth = (Width -> Width -> Width) -> [Width] -> Width
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Width -> Width -> Width
forall a. Ord a => a -> a -> a
max ([Width] -> Width) -> [Width] -> Width
forall a b. (a -> b) -> a -> b
$ (TermDisplay v a -> Width) -> [TermDisplay v a] -> [Width]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Width
P.Width (Int -> Width)
-> (TermDisplay v a -> Int) -> TermDisplay v a -> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Text) -> HashQualified Name -> Int
HQ'.nameLength Name -> Text
Name.toText (HashQualified Name -> Int)
-> (TermDisplay v a -> HashQualified Name)
-> TermDisplay v a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (HashQualified Name) (TermDisplay v a) (HashQualified Name)
-> TermDisplay v a -> HashQualified Name
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (HashQualified Name) (TermDisplay v a) (HashQualified Name)
#name) [TermDisplay v a]
newTerms
    prettyUpdateTerm (OBD.UpdateTermDisplay (Just [(HashQualified Name, Referent, Maybe (Type v a))]
olds) [TermDisplay v a]
news) = ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b.
(a -> b)
-> StateT (Int, Seq StructuredArgument) Identity a
-> StateT (Int, Seq StructuredArgument) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 (StateT
   (Int, Seq StructuredArgument)
   Identity
   [(Pretty ColorText, Pretty ColorText)]
 -> Numbered (Pretty ColorText))
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
-> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ do
      [(Pretty ColorText, Pretty ColorText)]
olds <-
        (TermDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse
          (AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTermLine AbsBranchId
oldPath Width
namesWidth)
          [HashQualified Name
-> Referent -> Maybe (Type v a) -> TermDisplay v a
forall v a.
HashQualified Name
-> Referent -> Maybe (Type v a) -> TermDisplay v a
OBD.TermDisplay HashQualified Name
name Referent
r Maybe (Type v a)
typ | (HashQualified Name
name, Referent
r, Maybe (Type v a)
typ) <- [(HashQualified Name, Referent, Maybe (Type v a))]
olds]
      [(Pretty ColorText, Pretty ColorText)]
news <- (TermDisplay v a
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      (Pretty ColorText, Pretty ColorText))
-> [TermDisplay v a]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
forall a.
AbsBranchId
-> Width
-> TermDisplay v a
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     (Pretty ColorText, Pretty ColorText)
mdTermLine AbsBranchId
newPath Width
namesWidth) [TermDisplay v a]
news
      let ([Pretty ColorText]
oldnums, [Pretty ColorText]
olddatas) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
olds
      let ([Pretty ColorText]
newnums, [Pretty ColorText]
newdatas) = [(Pretty ColorText, Pretty ColorText)]
-> ([Pretty ColorText], [Pretty ColorText])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Pretty ColorText, Pretty ColorText)]
news
      [(Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Pretty ColorText, Pretty ColorText)]
 -> StateT
      (Int, Seq StructuredArgument)
      Identity
      [(Pretty ColorText, Pretty ColorText)])
-> [(Pretty ColorText, Pretty ColorText)]
-> StateT
     (Int, Seq StructuredArgument)
     Identity
     [(Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> a -> b
$
        [Pretty ColorText]
-> [Pretty ColorText] -> [(Pretty ColorText, Pretty ColorText)]
forall a b. [a] -> [b] -> [(a, b)]
zip
          ([Pretty ColorText]
oldnums [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText
""] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText]
newnums)
          ([Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft [Pretty ColorText]
olddatas [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText
downArrow] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText] -> [Pretty ColorText]
forall s. (ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
P.boxLeft [Pretty ColorText]
newdatas)
      where
        namesWidth :: Width
namesWidth =
          (Width -> Width -> Width) -> [Width] -> Width
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' Width -> Width -> Width
forall a. Ord a => a -> a -> a
max ([Width] -> Width) -> [Width] -> Width
forall a b. (a -> b) -> a -> b
$
            (TermDisplay v a -> Width) -> [TermDisplay v a] -> [Width]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Width
P.Width (Int -> Width)
-> (TermDisplay v a -> Int) -> TermDisplay v a -> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Text) -> HashQualified Name -> Int
HQ'.nameLength Name -> Text
Name.toText (HashQualified Name -> Int)
-> (TermDisplay v a -> HashQualified Name)
-> TermDisplay v a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (HashQualified Name) (TermDisplay v a) (HashQualified Name)
-> TermDisplay v a -> HashQualified Name
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (HashQualified Name) (TermDisplay v a) (HashQualified Name)
#name) [TermDisplay v a]
news
              [Width] -> [Width] -> [Width]
forall a. Semigroup a => a -> a -> a
<> ((HashQualified Name, Referent, Maybe (Type v a)) -> Width)
-> [(HashQualified Name, Referent, Maybe (Type v a))] -> [Width]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Width
P.Width (Int -> Width)
-> ((HashQualified Name, Referent, Maybe (Type v a)) -> Int)
-> (HashQualified Name, Referent, Maybe (Type v a))
-> Width
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Text) -> HashQualified Name -> Int
HQ'.nameLength Name -> Text
Name.toText (HashQualified Name -> Int)
-> ((HashQualified Name, Referent, Maybe (Type v a))
    -> HashQualified Name)
-> (HashQualified Name, Referent, Maybe (Type v a))
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
  (HashQualified Name)
  (HashQualified Name, Referent, Maybe (Type v a))
  (HashQualified Name)
-> (HashQualified Name, Referent, Maybe (Type v a))
-> HashQualified Name
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (HashQualified Name)
  (HashQualified Name, Referent, Maybe (Type v a))
  (HashQualified Name)
forall s t a b. Field1 s t a b => Lens s t a b
Lens
  (HashQualified Name, Referent, Maybe (Type v a))
  (HashQualified Name, Referent, Maybe (Type v a))
  (HashQualified Name)
  (HashQualified Name)
_1) [(HashQualified Name, Referent, Maybe (Type v a))]
olds

    prettyType :: Maybe (Type v a) -> Pretty
    prettyType :: forall a. Maybe (Type v a) -> Pretty ColorText
prettyType = Pretty ColorText
-> (Type v a -> Pretty ColorText)
-> Maybe (Type v a)
-> Pretty ColorText
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
"type not found") (PrettyPrintEnv -> Type v a -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Type v a -> Pretty ColorText
TypePrinter.pretty PrettyPrintEnv
ppe)
    prettyDecl :: HashQualified Name -> Maybe (DeclOrBuiltin v a) -> Pretty ColorText
prettyDecl HashQualified Name
hq =
      Pretty ColorText
-> (DeclOrBuiltin v a -> Pretty ColorText)
-> Maybe (DeclOrBuiltin v a)
-> Pretty ColorText
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
        (Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
"type not found")
        (Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (DeclOrBuiltin v a -> Pretty (SyntaxText' TypeReference))
-> DeclOrBuiltin v a
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name
-> DeclOrBuiltin v a -> Pretty (SyntaxText' TypeReference)
forall v a.
Var v =>
HashQualified Name
-> DeclOrBuiltin v a -> Pretty (SyntaxText' TypeReference)
DeclPrinter.prettyDeclOrBuiltinHeader (HashQualified Name -> HashQualified Name
forall n. HashQualified n -> HashQualified n
HQ'.toHQ HashQualified Name
hq))
    HashQualified Name -> Pretty ColorText
phq' :: _ -> Pretty = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified'

    -- DeclPrinter.prettyDeclHeader : HQ -> Either
    numPatch :: Input.AbsBranchId -> Name -> Numbered Pretty
    numPatch :: AbsBranchId -> Name -> Numbered (Pretty ColorText)
numPatch AbsBranchId
prefix Name
name =
      StructuredArgument -> Numbered (Pretty ColorText)
addNumberedArg' (StructuredArgument -> Numbered (Pretty ColorText))
-> StructuredArgument -> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ AbsBranchId -> Name -> StructuredArgument
SA.NameWithBranchPrefix AbsBranchId
prefix Name
name

    numHQ' :: Input.AbsBranchId -> HQ'.HashQualified Name -> Referent -> Numbered Pretty
    numHQ' :: AbsBranchId
-> HashQualified Name -> Referent -> Numbered (Pretty ColorText)
numHQ' AbsBranchId
prefix HashQualified Name
hq Referent
r =
      StructuredArgument -> Numbered (Pretty ColorText)
addNumberedArg' (StructuredArgument -> Numbered (Pretty ColorText))
-> (HashQualified Name -> StructuredArgument)
-> HashQualified Name
-> Numbered (Pretty ColorText)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsBranchId -> HashQualified Name -> StructuredArgument
SA.HashQualifiedWithBranchPrefix AbsBranchId
prefix (HashQualified Name -> Numbered (Pretty ColorText))
-> HashQualified Name -> Numbered (Pretty ColorText)
forall a b. (a -> b) -> a -> b
$ HashQualified Name -> Referent -> HashQualified Name
HQ'.requalify HashQualified Name
hq Referent
r

    addNumberedArg' :: StructuredArgument -> Numbered Pretty
    addNumberedArg' :: StructuredArgument -> Numbered (Pretty ColorText)
addNumberedArg' StructuredArgument
s = case ShowNumbers
sn of
      ShowNumbers
ShowNumbers -> do
        Int
n <- StructuredArgument -> Numbered Int
addNumberedArg StructuredArgument
s
        pure $ Int -> Pretty ColorText
padNumber Int
n
      ShowNumbers
HideNumbers -> Pretty ColorText -> Numbered (Pretty ColorText)
forall a. a -> StateT (Int, Seq StructuredArgument) Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pretty ColorText
forall a. Monoid a => a
mempty

    padNumber :: Int -> Pretty
    padNumber :: Int -> Pretty ColorText
padNumber Int
n = Pretty ColorText -> Pretty ColorText
P.hiBlack (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Width -> Pretty ColorText -> Pretty ColorText
forall s. IsString s => Width -> Pretty s -> Pretty s
P.rightPad Width
leftNumsWidth (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."

    leftNumsWidth :: Width
leftNumsWidth = Int -> Width
P.Width (Int -> Width) -> Int -> Width
forall a b. (a -> b) -> a -> b
$ String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (Int -> String
forall a. Show a => a -> String
show Int
menuSize) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (String
"." :: String)

noResults :: Input.FindScope -> Pretty
noResults :: FindScope -> Pretty ColorText
noResults FindScope
fscope =
  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"😶" (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
    [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
      [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
          Pretty ColorText
"No results. Check your spelling, or try using tab completion "
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"to supply command arguments.",
        Pretty ColorText
""
      ]
        [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. [a] -> [a] -> [a]
++ case FindScope
fscope of
          FindScope
Input.FindGlobal -> []
          FindScope
_ -> [Pretty ColorText
suggestFindGlobal]
  where
    suggestFindGlobal :: Pretty ColorText
suggestFindGlobal =
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
        InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.findGlobal []
          Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"can be used to search outside the current namespace."

listOfDefinitions' ::
  (Var v) =>
  Input.FindScope ->
  PPE.PrettyPrintEnv -> -- for printing types of terms :-\
  E.ListDetailed ->
  [SR'.SearchResult' v a] ->
  Pretty
listOfDefinitions' :: forall v a.
Var v =>
FindScope
-> PrettyPrintEnv
-> Bool
-> [SearchResult' v a]
-> Pretty ColorText
listOfDefinitions' FindScope
fscope PrettyPrintEnv
ppe Bool
detailed [SearchResult' v a]
results =
  if [SearchResult' v a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SearchResult' v a]
results
    then FindScope -> Pretty ColorText
noResults FindScope
fscope
    else
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        ([Pretty ColorText] -> Pretty ColorText)
-> ([Pretty ColorText] -> [Pretty ColorText])
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> [Pretty ColorText]
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> [Pretty s]
P.nonEmpty
        ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
prettyNumberedResults
          Pretty ColorText -> [Pretty ColorText] -> [Pretty ColorText]
forall a. a -> [a] -> [a]
: [ [(HashQualified Name, ShortHash)]
-> [(HashQualified Name, ShortHash)] -> Pretty ColorText
forall tm typ.
(Show tm, Show typ) =>
[(HashQualified Name, tm)]
-> [(HashQualified Name, typ)] -> Pretty ColorText
formatMissingStuff [(HashQualified Name, ShortHash)]
termsWithMissingTypes [(HashQualified Name, ShortHash)]
missingTypes,
              Bool -> Pretty ColorText -> Pretty ColorText
forall a. Monoid a => Bool -> a -> a
Monoid.unlessM ([(HashQualified Name, Referent)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(HashQualified Name, Referent)]
missingBuiltins)
                (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
bigproblem
                (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap
                  Pretty ColorText
"I encountered an inconsistency in the codebase; these definitions refer to built-ins that this version of unison doesn't know about:"
                  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
`P.hang` [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2
                    ( (Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Name", Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Built-in")
                        -- : ("-", "-")
                        (Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
: ((HashQualified Name, Referent)
 -> (Pretty ColorText, Pretty ColorText))
-> [(HashQualified Name, Referent)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
                          ( (HashQualified Name -> Pretty ColorText)
-> (Referent -> Pretty ColorText)
-> (HashQualified Name, Referent)
-> (Pretty ColorText, Pretty ColorText)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap
                              (Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified)
                              (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText)
-> (Referent -> Text) -> Referent -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Referent -> Text
Referent.toText)
                          )
                          [(HashQualified Name, Referent)]
missingBuiltins
                    )
            ]
  where
    prettyNumberedResults :: Pretty ColorText
prettyNumberedResults = [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList [Pretty ColorText]
prettyResults
    -- todo: group this by namespace
    prettyResults :: [Pretty ColorText]
prettyResults =
      (SearchResult' v a -> Pretty ColorText)
-> [SearchResult' v a] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
map
        ((TermResult' v a -> Pretty ColorText)
-> (TypeResult' v a -> Pretty ColorText)
-> SearchResult' v a
-> Pretty ColorText
forall v a b.
(TermResult' v a -> b)
-> (TypeResult' v a -> b) -> SearchResult' v a -> b
SR'.foldResult' TermResult' v a -> Pretty ColorText
renderTerm TypeResult' v a -> Pretty ColorText
renderType)
        ((SearchResult' v a -> Bool)
-> [SearchResult' v a] -> [SearchResult' v a]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (SearchResult' v a -> Bool) -> SearchResult' v a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SearchResult' v a -> Bool
forall {v} {a}. SearchResult' v a -> Bool
missingType) [SearchResult' v a]
results)
      where
        (TermResult' v a -> Pretty ColorText
renderTerm, TypeResult' v a -> Pretty ColorText
renderType) =
          if Bool
detailed
            then (PrettyPrintEnv -> TermResult' v a -> Pretty ColorText
forall v a.
Var v =>
PrettyPrintEnv -> TermResult' v a -> Pretty ColorText
unsafePrettyTermResultSigFull' PrettyPrintEnv
ppe, TypeResult' v a -> Pretty ColorText
forall v a. Var v => TypeResult' v a -> Pretty ColorText
prettyTypeResultHeaderFull')
            else (PrettyPrintEnv -> TermResult' v a -> Pretty ColorText
forall v a.
Var v =>
PrettyPrintEnv -> TermResult' v a -> Pretty ColorText
unsafePrettyTermResultSig' PrettyPrintEnv
ppe, TypeResult' v a -> Pretty ColorText
forall v a. Var v => TypeResult' v a -> Pretty ColorText
prettyTypeResultHeader')
    missingType :: SearchResult' v a -> Bool
missingType (SR'.Tm HashQualified Name
_ Maybe (Type v a)
Nothing Referent
_ Set (HashQualified Name)
_) = Bool
True
    missingType (SR'.Tp HashQualified Name
_ (MissingObject ShortHash
_) TypeReference
_ Set (HashQualified Name)
_) = Bool
True
    missingType SearchResult' v a
_ = Bool
False
    -- termsWithTypes = [(name,t) | (name, Just t) <- sigs0 ]
    --   where sigs0 = (\(name, _, typ) -> (name, typ)) <$> terms
    termsWithMissingTypes :: [(HashQualified Name, ShortHash)]
termsWithMissingTypes =
      [ (HashQualified Name
name, TermReferenceId -> ShortHash
Reference.idToShortHash TermReferenceId
r)
        | SR'.Tm HashQualified Name
name Maybe (Type v a)
Nothing (Referent.Ref (Reference.DerivedId TermReferenceId
r)) Set (HashQualified Name)
_ <- [SearchResult' v a]
results
      ]
    missingTypes :: [(HashQualified Name, ShortHash)]
missingTypes =
      ((HashQualified Name, ShortHash) -> ShortHash)
-> [(HashQualified Name, ShortHash)]
-> [(HashQualified Name, ShortHash)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
nubOrdOn (HashQualified Name, ShortHash) -> ShortHash
forall a b. (a, b) -> b
snd ([(HashQualified Name, ShortHash)]
 -> [(HashQualified Name, ShortHash)])
-> [(HashQualified Name, ShortHash)]
-> [(HashQualified Name, ShortHash)]
forall a b. (a -> b) -> a -> b
$
        [(HashQualified Name
name, ShortHash
r) | SR'.Tp HashQualified Name
name (MissingObject ShortHash
r) TypeReference
_ Set (HashQualified Name)
_ <- [SearchResult' v a]
results]
          [(HashQualified Name, ShortHash)]
-> [(HashQualified Name, ShortHash)]
-> [(HashQualified Name, ShortHash)]
forall a. Semigroup a => a -> a -> a
<> [ (HashQualified Name
name, TypeReference -> ShortHash
Reference.toShortHash TypeReference
r)
               | SR'.Tm HashQualified Name
name Maybe (Type v a)
Nothing (Referent -> Maybe TypeReference
forall r. Referent' r -> Maybe r
Referent.toTypeReference -> Just TypeReference
r) Set (HashQualified Name)
_ <- [SearchResult' v a]
results
             ]
    missingBuiltins :: [(HashQualified Name, Referent)]
missingBuiltins =
      [SearchResult' v a]
results [SearchResult' v a]
-> (SearchResult' v a -> [(HashQualified Name, Referent)])
-> [(HashQualified Name, Referent)]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
        SR'.Tm HashQualified Name
name Maybe (Type v a)
Nothing r :: Referent
r@(Referent.Ref (Reference.Builtin Text
_)) Set (HashQualified Name)
_ ->
          [(HashQualified Name
name, Referent
r)]
        SearchResult' v a
_ -> []

watchPrinter ::
  (Var v) =>
  Text ->
  PPE.PrettyPrintEnv ->
  Ann ->
  WK.WatchKind ->
  Term v () ->
  Runtime.IsCacheHit ->
  Pretty
watchPrinter :: forall v.
Var v =>
Text
-> PrettyPrintEnv
-> Ann
-> String
-> Term v ()
-> Bool
-> Pretty ColorText
watchPrinter Text
src PrettyPrintEnv
ppe Ann
ann String
kind Term (F v () ()) v ()
term Bool
isHit =
  Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.bracket (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
    let lines :: [Text]
lines = Text -> [Text]
Text.lines Text
src
        lineNum :: Int
lineNum = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
1 (Maybe Int -> Int) -> Maybe Int -> Int
forall a b. (a -> b) -> a -> b
$ Ann -> Maybe Int
startingLine Ann
ann
        lineNumWidth :: Int
lineNumWidth = String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (Int -> String
forall a. Show a => a -> String
show Int
lineNum)
        extra :: String
extra = String
"     " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> Char -> String
forall a. Int -> a -> [a]
replicate (String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
kind) Char
' ' -- for the ` | > ` after the line number
        line :: Text
line = [Text]
lines [Text] -> Int -> Text
forall a. HasCallStack => [a] -> Int -> a
!! (Int
lineNum Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
        addCache :: Pretty ColorText -> Pretty ColorText
addCache Pretty ColorText
p = if Bool
isHit then Pretty ColorText
p Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" (cached)" else Pretty ColorText
p
        renderTest :: Term (F v () ()) v () -> Pretty ColorText
renderTest (Term.App' (Term.Constructor' (ConstructorReference TypeReference
_ ConstructorId
id)) (Term.Text' Text
msg)) =
          Pretty ColorText
"\n"
            Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> if ConstructorId
id ConstructorId -> ConstructorId -> Bool
forall a. Eq a => a -> a -> Bool
== ConstructorId
DD.okConstructorId
              then
                Pretty ColorText -> Pretty ColorText
addCache
                  (Pretty ColorText -> Pretty ColorText
P.green Pretty ColorText
"✅ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Passed" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.green (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
msg'))
              else
                if ConstructorId
id ConstructorId -> ConstructorId -> Bool
forall a. Eq a => a -> a -> Bool
== ConstructorId
DD.failConstructorId
                  then
                    Pretty ColorText -> Pretty ColorText
addCache
                      (Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
"🚫 " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"FAILED" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText -> Pretty ColorText
P.red (Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
msg'))
                  else Pretty ColorText -> Pretty ColorText
P.red Pretty ColorText
"❓ " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> Term (F v () ()) v () -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Term v a -> Pretty ColorText
TermPrinter.pretty PrettyPrintEnv
ppe Term (F v () ()) v ()
term
          where
            msg' :: Text
msg' =
              if Int -> Text -> Text
Text.take Int
1 Text
msg Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
" "
                then Text
msg
                else Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
msg
        renderTest Term (F v () ()) v ()
x =
          String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (String -> Pretty ColorText) -> String -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ String
"\n Unison bug: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Term (F v () ()) v () -> String
forall a. Show a => a -> String
show Term (F v () ()) v ()
x String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" is not a test."
     in [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (Int -> String
forall a. Show a => a -> String
show Int
lineNum) Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" | " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
line,
            case (String
kind, Term (F v () ()) v ()
term) of
              (String
WK.TestWatch, Term.List' Seq (Term (F v () ()) v ())
tests) -> (Term (F v () ()) v () -> Pretty ColorText)
-> Seq (Term (F v () ()) v ()) -> Pretty ColorText
forall m a. Monoid m => (a -> m) -> Seq a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Term (F v () ()) v () -> Pretty ColorText
renderTest Seq (Term (F v () ()) v ())
tests
              (String, Term (F v () ()) v ())
_ ->
                [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                  [ String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
lineNumWidth Char
' ')
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> String -> Pretty ColorText
forall a. IsString a => String -> a
fromString String
extra
                      Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> (if Bool
isHit then Pretty ColorText -> Pretty ColorText
forall a. a -> a
id else Pretty ColorText -> Pretty ColorText
P.purple) Pretty ColorText
"⧩",
                    Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN (Int -> Width
P.Width (Int
lineNumWidth Int -> Int -> Int
forall a. Num a => a -> a -> a
+ String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
extra))
                      (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (if Bool
isHit then Pretty ColorText -> Pretty ColorText
forall a. a -> a
id else Pretty ColorText -> Pretty ColorText
P.bold)
                      (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ PrettyPrintEnv -> Term (F v () ()) v () -> Pretty ColorText
forall v a. Var v => PrettyPrintEnv -> Term v a -> Pretty ColorText
TermPrinter.pretty PrettyPrintEnv
ppe Term (F v () ()) v ()
term
                  ]
          ]

filestatusTip :: Pretty
filestatusTip :: Pretty ColorText
filestatusTip = Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip Pretty ColorText
"Use `help filestatus` to learn more."

prettyDiff :: Names.Diff -> Pretty
prettyDiff :: Diff -> Pretty ColorText
prettyDiff Diff
diff =
  let orig :: Names
orig = Diff -> Names
Names.originalNames Diff
diff
      adds :: Names
adds = Diff -> Names
Names.addedNames Diff
diff
      removes :: Names
removes = Diff -> Names
Names.removedNames Diff
diff

      addedTerms :: [(Name, Referent)]
addedTerms =
        [ (Name
n, Referent
r) | (Name
n, Referent
r) <- Relation Name Referent -> [(Name, Referent)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name Referent
Names.terms Names
adds), Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Referent -> Relation Name Referent -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan Referent
r (Names -> Relation Name Referent
Names.terms Names
removes)
        ]
      addedTypes :: [(Name, TypeReference)]
addedTypes =
        [ (Name
n, TypeReference
r) | (Name
n, TypeReference
r) <- Relation Name TypeReference -> [(Name, TypeReference)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name TypeReference
Names.types Names
adds), Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ TypeReference -> Relation Name TypeReference -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan TypeReference
r (Names -> Relation Name TypeReference
Names.types Names
removes)
        ]
      added :: [HashQualified Name]
added = (HashQualified Name -> HashQualified Name -> Ordering)
-> [HashQualified Name] -> [HashQualified Name]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy HashQualified Name -> HashQualified Name -> Ordering
forall n. Alphabetical n => n -> n -> Ordering
Name.compareAlphabetical ([HashQualified Name]
hqTerms [HashQualified Name]
-> [HashQualified Name] -> [HashQualified Name]
forall a. [a] -> [a] -> [a]
++ [HashQualified Name]
hqTypes)
        where
          hqTerms :: [HashQualified Name]
hqTerms = [Names
-> Name -> Either TypeReference Referent -> HashQualified Name
Names.hqName Names
adds Name
n (Referent -> Either TypeReference Referent
forall a b. b -> Either a b
Right Referent
r) | (Name
n, Referent
r) <- [(Name, Referent)]
addedTerms]
          hqTypes :: [HashQualified Name]
hqTypes = [Names
-> Name -> Either TypeReference Referent -> HashQualified Name
Names.hqName Names
adds Name
n (TypeReference -> Either TypeReference Referent
forall a b. a -> Either a b
Left TypeReference
r) | (Name
n, TypeReference
r) <- [(Name, TypeReference)]
addedTypes]

      removedTerms :: [(Name, Referent)]
removedTerms =
        [ (Name
n, Referent
r) | (Name
n, Referent
r) <- Relation Name Referent -> [(Name, Referent)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name Referent
Names.terms Names
removes), Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Referent -> Relation Name Referent -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan Referent
r (Names -> Relation Name Referent
Names.terms Names
adds), Name -> Set Name -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.notMember Name
n Set Name
addedTermsSet
        ]
        where
          addedTermsSet :: Set Name
addedTermsSet = [Name] -> Set Name
forall a. Ord a => [a] -> Set a
Set.fromList (((Name, Referent) -> Name) -> [(Name, Referent)] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map (Name, Referent) -> Name
forall a b. (a, b) -> a
fst [(Name, Referent)]
addedTerms)
      removedTypes :: [(Name, TypeReference)]
removedTypes =
        [ (Name
n, TypeReference
r) | (Name
n, TypeReference
r) <- Relation Name TypeReference -> [(Name, TypeReference)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name TypeReference
Names.types Names
removes), Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ TypeReference -> Relation Name TypeReference -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan TypeReference
r (Names -> Relation Name TypeReference
Names.types Names
adds), Name -> Set Name -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.notMember Name
n Set Name
addedTypesSet
        ]
        where
          addedTypesSet :: Set Name
addedTypesSet = [Name] -> Set Name
forall a. Ord a => [a] -> Set a
Set.fromList (((Name, TypeReference) -> Name)
-> [(Name, TypeReference)] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map (Name, TypeReference) -> Name
forall a b. (a, b) -> a
fst [(Name, TypeReference)]
addedTypes)
      removed :: [HashQualified Name]
removed = (HashQualified Name -> HashQualified Name -> Ordering)
-> [HashQualified Name] -> [HashQualified Name]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy HashQualified Name -> HashQualified Name -> Ordering
forall n. Alphabetical n => n -> n -> Ordering
Name.compareAlphabetical ([HashQualified Name]
hqTerms [HashQualified Name]
-> [HashQualified Name] -> [HashQualified Name]
forall a. [a] -> [a] -> [a]
++ [HashQualified Name]
hqTypes)
        where
          hqTerms :: [HashQualified Name]
hqTerms = [Names
-> Name -> Either TypeReference Referent -> HashQualified Name
Names.hqName Names
removes Name
n (Referent -> Either TypeReference Referent
forall a b. b -> Either a b
Right Referent
r) | (Name
n, Referent
r) <- [(Name, Referent)]
removedTerms]
          hqTypes :: [HashQualified Name]
hqTypes = [Names
-> Name -> Either TypeReference Referent -> HashQualified Name
Names.hqName Names
removes Name
n (TypeReference -> Either TypeReference Referent
forall a b. a -> Either a b
Left TypeReference
r) | (Name
n, TypeReference
r) <- [(Name, TypeReference)]
removedTypes]

      movedTerms :: [(Name, Name)]
movedTerms =
        [ (Name
n, Name
n2) | (Name
n, Referent
r) <- Relation Name Referent -> [(Name, Referent)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name Referent
Names.terms Names
removes), Name
n2 <- Set Name -> [Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Referent -> Relation Name Referent -> Set Name
forall b a. Ord b => b -> Relation a b -> Set a
R.lookupRan Referent
r (Names -> Relation Name Referent
Names.terms Names
adds))
        ]
      movedTypes :: [(Name, Name)]
movedTypes =
        [ (Name
n, Name
n2) | (Name
n, TypeReference
r) <- Relation Name TypeReference -> [(Name, TypeReference)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name TypeReference
Names.types Names
removes), Name
n2 <- Set Name -> [Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (TypeReference -> Relation Name TypeReference -> Set Name
forall b a. Ord b => b -> Relation a b -> Set a
R.lookupRan TypeReference
r (Names -> Relation Name TypeReference
Names.types Names
adds))
        ]
      moved :: [(Name, Name)]
moved = (Name -> Text)
-> ((Name, Name) -> Name) -> [(Name, Name)] -> [(Name, Name)]
forall a. (Name -> Text) -> (a -> Name) -> [a] -> [a]
Name.sortNamed Name -> Text
Name.toText (Name, Name) -> Name
forall a b. (a, b) -> a
fst ([(Name, Name)] -> [(Name, Name)])
-> ([(Name, Name)] -> [(Name, Name)])
-> [(Name, Name)]
-> [(Name, Name)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Name, Name)] -> [(Name, Name)]
forall a. Ord a => [a] -> [a]
nubOrd ([(Name, Name)] -> [(Name, Name)])
-> [(Name, Name)] -> [(Name, Name)]
forall a b. (a -> b) -> a -> b
$ ([(Name, Name)]
movedTerms [(Name, Name)] -> [(Name, Name)] -> [(Name, Name)]
forall a. Semigroup a => a -> a -> a
<> [(Name, Name)]
movedTypes)

      copiedTerms :: Map Name [Name]
copiedTerms =
        [(Name, Name)] -> Map Name [Name]
forall (f :: * -> *) k v.
(Foldable f, Ord k) =>
f (k, v) -> Map k [v]
List.multimap
          [ (Name
n, Name
n2) | (Name
n2, Referent
r) <- Relation Name Referent -> [(Name, Referent)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name Referent
Names.terms Names
adds), Bool -> Bool
not (Referent -> Relation Name Referent -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan Referent
r (Names -> Relation Name Referent
Names.terms Names
removes)), Name
n <- Set Name -> [Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Referent -> Relation Name Referent -> Set Name
forall b a. Ord b => b -> Relation a b -> Set a
R.lookupRan Referent
r (Names -> Relation Name Referent
Names.terms Names
orig))
          ]
      copiedTypes :: Map Name [Name]
copiedTypes =
        [(Name, Name)] -> Map Name [Name]
forall (f :: * -> *) k v.
(Foldable f, Ord k) =>
f (k, v) -> Map k [v]
List.multimap
          [ (Name
n, Name
n2) | (Name
n2, TypeReference
r) <- Relation Name TypeReference -> [(Name, TypeReference)]
forall a b. Relation a b -> [(a, b)]
R.toList (Names -> Relation Name TypeReference
Names.types Names
adds), Bool -> Bool
not (TypeReference -> Relation Name TypeReference -> Bool
forall b a. Ord b => b -> Relation a b -> Bool
R.memberRan TypeReference
r (Names -> Relation Name TypeReference
Names.types Names
removes)), Name
n <- Set Name -> [Name]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (TypeReference -> Relation Name TypeReference -> Set Name
forall b a. Ord b => b -> Relation a b -> Set a
R.lookupRan TypeReference
r (Names -> Relation Name TypeReference
Names.types Names
orig))
          ]
      copied :: [(Name, [Name])]
copied =
        (Name -> Text)
-> ((Name, [Name]) -> Name) -> [(Name, [Name])] -> [(Name, [Name])]
forall a. (Name -> Text) -> (a -> Name) -> [a] -> [a]
Name.sortNamed Name -> Text
Name.toText (Name, [Name]) -> Name
forall a b. (a, b) -> a
fst ([(Name, [Name])] -> [(Name, [Name])])
-> [(Name, [Name])] -> [(Name, [Name])]
forall a b. (a -> b) -> a -> b
$
          Map Name [Name] -> [(Name, [Name])]
forall k a. Map k a -> [(k, a)]
Map.toList (([Name] -> [Name] -> [Name])
-> Map Name [Name] -> Map Name [Name] -> Map Name [Name]
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith [Name] -> [Name] -> [Name]
forall a. Semigroup a => a -> a -> a
(<>) Map Name [Name]
copiedTerms Map Name [Name]
copiedTypes)
   in Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty
        Pretty ColorText
"\n\n"
        [ if Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
added
            then
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ -- todo: split out updates
                  Pretty ColorText -> Pretty ColorText
P.green Pretty ColorText
"+ Adds / updates:",
                  Pretty ColorText
"",
                  Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
" " (Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
added)
                ]
            else Pretty ColorText
forall a. Monoid a => a
mempty,
          if Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
removed
            then
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"- Deletes:",
                  Pretty ColorText
"",
                  Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
" " (Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified' (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
removed)
                ]
            else Pretty ColorText
forall a. Monoid a => a
mempty,
          if Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [(Name, Name)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Name, Name)]
moved
            then
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ Pretty ColorText -> Pretty ColorText
P.purple Pretty ColorText
"> Moves:",
                  Pretty ColorText
"",
                  Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                      (Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"Original name", Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"New name")
                        (Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
: [(Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n2) | (Name
n, Name
n2) <- [(Name, Name)]
moved]
                ]
            else Pretty ColorText
forall a. Monoid a => a
mempty,
          if Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [(Name, [Name])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Name, [Name])]
copied
            then
              [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
                [ Pretty ColorText -> Pretty ColorText
P.yellow Pretty ColorText
"= Copies:",
                  Pretty ColorText
"",
                  Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                    [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
[(Pretty s, Pretty s)] -> Pretty s
P.column2 ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
                      (Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"Original name", Pretty ColorText -> Pretty ColorText
P.hiBlack Pretty ColorText
"New name(s)")
                        (Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
: [ (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName Name
n, Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sep Pretty ColorText
" " (Name -> Pretty ColorText
forall s. IsString s => Name -> Pretty s
prettyName (Name -> Pretty ColorText) -> [Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Name]
ns))
                            | (Name
n, [Name]
ns) <- [(Name, [Name])]
copied
                          ]
                ]
            else Pretty ColorText
forall a. Monoid a => a
mempty
        ]

-- | Get the list of numbered args corresponding to an endangerment map, which is used by a
-- few outputs. See 'endangeredDependentsTable'.
numberedArgsForEndangerments ::
  PPED.PrettyPrintEnvDecl ->
  Map LabeledDependency (NESet LabeledDependency) ->
  NumberedArgs
numberedArgsForEndangerments :: PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency) -> NumberedArgs
numberedArgsForEndangerments (PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.unsuffixifiedPPE -> PrettyPrintEnv
ppe) Map LabeledDependency (NESet LabeledDependency)
m =
  Map LabeledDependency (NESet LabeledDependency)
m
    Map LabeledDependency (NESet LabeledDependency)
-> (Map LabeledDependency (NESet LabeledDependency)
    -> [NESet LabeledDependency])
-> [NESet LabeledDependency]
forall a b. a -> (a -> b) -> b
& Map LabeledDependency (NESet LabeledDependency)
-> [NESet LabeledDependency]
forall k a. Map k a -> [a]
Map.elems
    [NESet LabeledDependency]
-> ([NESet LabeledDependency] -> [LabeledDependency])
-> [LabeledDependency]
forall a b. a -> (a -> b) -> b
& (NESet LabeledDependency -> [LabeledDependency])
-> [NESet LabeledDependency] -> [LabeledDependency]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap NESet LabeledDependency -> [LabeledDependency]
forall a. NESet a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
    [LabeledDependency]
-> ([LabeledDependency] -> NumberedArgs) -> NumberedArgs
forall a b. a -> (a -> b) -> b
& (LabeledDependency -> StructuredArgument)
-> [LabeledDependency] -> NumberedArgs
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (HashQualified Name -> StructuredArgument
SA.HashQualified (HashQualified Name -> StructuredArgument)
-> (LabeledDependency -> HashQualified Name)
-> LabeledDependency
-> StructuredArgument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyPrintEnv -> LabeledDependency -> HashQualified Name
PPE.labeledRefName PrettyPrintEnv
ppe)

-- | Format and render all dependents which are endangered by references going extinct.
endangeredDependentsTable ::
  PPED.PrettyPrintEnvDecl ->
  Map LabeledDependency (NESet LabeledDependency) ->
  P.Pretty P.ColorText
endangeredDependentsTable :: PrettyPrintEnvDecl
-> Map LabeledDependency (NESet LabeledDependency)
-> Pretty ColorText
endangeredDependentsTable PrettyPrintEnvDecl
ppeDecl Map LabeledDependency (NESet LabeledDependency)
m =
  Map LabeledDependency (NESet LabeledDependency)
m
    Map LabeledDependency (NESet LabeledDependency)
-> (Map LabeledDependency (NESet LabeledDependency)
    -> [(LabeledDependency, NESet LabeledDependency)])
-> [(LabeledDependency, NESet LabeledDependency)]
forall a b. a -> (a -> b) -> b
& Map LabeledDependency (NESet LabeledDependency)
-> [(LabeledDependency, NESet LabeledDependency)]
forall k a. Map k a -> [(k, a)]
Map.toList
    [(LabeledDependency, NESet LabeledDependency)]
-> ([(LabeledDependency, NESet LabeledDependency)]
    -> [(LabeledDependency, [LabeledDependency])])
-> [(LabeledDependency, [LabeledDependency])]
forall a b. a -> (a -> b) -> b
& ((LabeledDependency, NESet LabeledDependency)
 -> (LabeledDependency, [LabeledDependency]))
-> [(LabeledDependency, NESet LabeledDependency)]
-> [(LabeledDependency, [LabeledDependency])]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((NESet LabeledDependency -> [LabeledDependency])
-> (LabeledDependency, NESet LabeledDependency)
-> (LabeledDependency, [LabeledDependency])
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second NESet LabeledDependency -> [LabeledDependency]
forall a. NESet a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList)
    [(LabeledDependency, [LabeledDependency])]
-> ([(LabeledDependency, [LabeledDependency])]
    -> [(LabeledDependency, [(Int, LabeledDependency)])])
-> [(LabeledDependency, [(Int, LabeledDependency)])]
forall a b. a -> (a -> b) -> b
& [(LabeledDependency, [LabeledDependency])]
-> [(LabeledDependency, [(Int, LabeledDependency)])]
forall x.
[(x, [LabeledDependency])] -> [(x, [(Int, LabeledDependency)])]
numberDependents
    [(LabeledDependency, [(Int, LabeledDependency)])]
-> ([(LabeledDependency, [(Int, LabeledDependency)])]
    -> [(Pretty ColorText, Pretty ColorText)])
-> [(Pretty ColorText, Pretty ColorText)]
forall a b. a -> (a -> b) -> b
& ((LabeledDependency, [(Int, LabeledDependency)])
 -> (Pretty ColorText, Pretty ColorText))
-> [(LabeledDependency, [(Int, LabeledDependency)])]
-> [(Pretty ColorText, Pretty ColorText)]
forall a b. (a -> b) -> [a] -> [b]
map
      ( \(LabeledDependency
dependency, [(Int, LabeledDependency)]
dependents) ->
          (PrettyPrintEnv -> LabeledDependency -> Pretty ColorText
prettyLabeled PrettyPrintEnv
suffixifiedEnv LabeledDependency
dependency, [(Int, LabeledDependency)] -> Pretty ColorText
prettyDependents [(Int, LabeledDependency)]
dependents)
      )
    [(Pretty ColorText, Pretty ColorText)]
-> ([(Pretty ColorText, Pretty ColorText)]
    -> [(Pretty ColorText, Pretty ColorText)])
-> [(Pretty ColorText, Pretty ColorText)]
forall a b. a -> (a -> b) -> b
& (Pretty ColorText, Pretty ColorText)
-> [(Pretty ColorText, Pretty ColorText)]
-> [(Pretty ColorText, Pretty ColorText)]
forall a. a -> [a] -> [a]
List.intersperse (Pretty ColorText, Pretty ColorText)
spacer
    [(Pretty ColorText, Pretty ColorText)]
-> ([(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText)
-> Pretty ColorText
forall a b. a -> (a -> b) -> b
& Pretty ColorText
-> Pretty ColorText
-> [(Pretty ColorText, Pretty ColorText)]
-> Pretty ColorText
P.column2Header Pretty ColorText
"Dependency" Pretty ColorText
"Referenced In"
  where
    numberDependents :: [(x, [LabeledDependency])] -> [(x, [(Int, LabeledDependency)])]
    numberDependents :: forall x.
[(x, [LabeledDependency])] -> [(x, [(Int, LabeledDependency)])]
numberDependents [(x, [LabeledDependency])]
xs =
      let (Int
_acc, [(x, [(Int, LabeledDependency)])]
numbered) =
            LensLike
  (StateT Int Identity)
  [(x, [LabeledDependency])]
  [(x, [(Int, LabeledDependency)])]
  LabeledDependency
  (Int, LabeledDependency)
-> (Int -> LabeledDependency -> (Int, (Int, LabeledDependency)))
-> Int
-> [(x, [LabeledDependency])]
-> (Int, [(x, [(Int, LabeledDependency)])])
forall acc s t a b.
LensLike (State acc) s t a b
-> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumLOf
              (((x, [LabeledDependency])
 -> StateT Int Identity (x, [(Int, LabeledDependency)]))
-> [(x, [LabeledDependency])]
-> StateT Int Identity [(x, [(Int, LabeledDependency)])]
forall (f :: * -> *) a b.
Traversable f =>
IndexedTraversal Int (f a) (f b) a b
IndexedTraversal
  Int
  [(x, [LabeledDependency])]
  [(x, [(Int, LabeledDependency)])]
  (x, [LabeledDependency])
  (x, [(Int, LabeledDependency)])
traversed (((x, [LabeledDependency])
  -> StateT Int Identity (x, [(Int, LabeledDependency)]))
 -> [(x, [LabeledDependency])]
 -> StateT Int Identity [(x, [(Int, LabeledDependency)])])
-> ((LabeledDependency -> State Int (Int, LabeledDependency))
    -> (x, [LabeledDependency])
    -> StateT Int Identity (x, [(Int, LabeledDependency)]))
-> LensLike
     (StateT Int Identity)
     [(x, [LabeledDependency])]
     [(x, [(Int, LabeledDependency)])]
     LabeledDependency
     (Int, LabeledDependency)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([LabeledDependency]
 -> StateT Int Identity [(Int, LabeledDependency)])
-> (x, [LabeledDependency])
-> StateT Int Identity (x, [(Int, LabeledDependency)])
forall s t a b. Field2 s t a b => Lens s t a b
Lens
  (x, [LabeledDependency])
  (x, [(Int, LabeledDependency)])
  [LabeledDependency]
  [(Int, LabeledDependency)]
_2 (([LabeledDependency]
  -> StateT Int Identity [(Int, LabeledDependency)])
 -> (x, [LabeledDependency])
 -> StateT Int Identity (x, [(Int, LabeledDependency)]))
-> ((LabeledDependency -> State Int (Int, LabeledDependency))
    -> [LabeledDependency]
    -> StateT Int Identity [(Int, LabeledDependency)])
-> (LabeledDependency -> State Int (Int, LabeledDependency))
-> (x, [LabeledDependency])
-> StateT Int Identity (x, [(Int, LabeledDependency)])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LabeledDependency -> State Int (Int, LabeledDependency))
-> [LabeledDependency]
-> StateT Int Identity [(Int, LabeledDependency)]
forall (f :: * -> *) a b.
Traversable f =>
IndexedTraversal Int (f a) (f b) a b
IndexedTraversal
  Int
  [LabeledDependency]
  [(Int, LabeledDependency)]
  LabeledDependency
  (Int, LabeledDependency)
traversed)
              (\Int
n LabeledDependency
ld -> (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1, (Int
n, LabeledDependency
ld)))
              Int
1
              [(x, [LabeledDependency])]
xs
       in [(x, [(Int, LabeledDependency)])]
numbered
    spacer :: (Pretty ColorText, Pretty ColorText)
spacer = (Pretty ColorText
"", Pretty ColorText
"")
    suffixifiedEnv :: PrettyPrintEnv
suffixifiedEnv = (PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.suffixifiedPPE PrettyPrintEnvDecl
ppeDecl)
    fqnEnv :: PrettyPrintEnv
fqnEnv = (PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.unsuffixifiedPPE PrettyPrintEnvDecl
ppeDecl)
    prettyLabeled :: PrettyPrintEnv -> LabeledDependency -> Pretty ColorText
prettyLabeled PrettyPrintEnv
ppe = \case
      LD.TermReferent Referent
ref -> PrettyPrintEnv -> Referent -> Pretty ColorText
prettyTermName PrettyPrintEnv
ppe Referent
ref
      LD.TypeReference TypeReference
ref -> PrettyPrintEnv -> TypeReference -> Pretty ColorText
prettyTypeName PrettyPrintEnv
ppe TypeReference
ref
    numArg :: Int -> Pretty ColorText
numArg = (\Int
n -> Pretty ColorText -> Pretty ColorText
P.hiBlack (Pretty ColorText -> Pretty ColorText)
-> (String -> Pretty ColorText) -> String -> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Pretty ColorText
forall a. IsString a => String -> a
fromString (String -> Pretty ColorText) -> String -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
n String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
". ")
    prettyDependents :: [(Int, LabeledDependency)] -> Pretty ColorText
prettyDependents [(Int, LabeledDependency)]
refs =
      [(Int, LabeledDependency)]
refs
        [(Int, LabeledDependency)]
-> ([(Int, LabeledDependency)] -> [Pretty ColorText])
-> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& ((Int, LabeledDependency) -> Pretty ColorText)
-> [(Int, LabeledDependency)] -> [Pretty ColorText]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
n, LabeledDependency
dep) -> Int -> Pretty ColorText
numArg Int
n Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> LabeledDependency -> Pretty ColorText
prettyLabeled PrettyPrintEnv
fqnEnv LabeledDependency
dep)
        [Pretty ColorText]
-> ([Pretty ColorText] -> Pretty ColorText) -> Pretty ColorText
forall a b. a -> (a -> b) -> b
& [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines

listFind :: Bool -> Maybe Pretty -> [HQ.HashQualified Name] -> Pretty
listFind :: Bool
-> Maybe (Pretty ColorText)
-> [HashQualified Name]
-> Pretty ColorText
listFind Bool
_ Maybe (Pretty ColorText)
Nothing [] = Pretty ColorText
"😶 I couldn't find any matches."
listFind Bool
_ (Just Pretty ColorText
onMissing) [] = [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines [Pretty ColorText
"😶 I couldn't find any matches.", Pretty ColorText
"", Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip Pretty ColorText
onMissing]
listFind Bool
allowLib Maybe (Pretty ColorText)
_ [HashQualified Name]
tms =
  Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Pretty s -> Pretty s -> Pretty s
P.callout Pretty ColorText
"🔎" (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
    [ Pretty ColorText
"These definitions from the current namespace " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
parenthetical Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"have matches:",
      Pretty ColorText
"",
      Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList ([HashQualified Name] -> [Pretty ColorText]
forall {f :: * -> *}.
Functor f =>
f (HashQualified Name) -> f (Pretty ColorText)
pnames [HashQualified Name]
tms),
      Pretty ColorText
"",
      Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Int -> Pretty ColorText
forall {a}. (Eq a, Num a, Show a) => a -> Pretty ColorText
msg ([HashQualified Name] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [HashQualified Name]
tms))
    ]
  where
    parenthetical :: Pretty ColorText
parenthetical = if Bool
allowLib then Pretty ColorText
"" else Pretty ColorText
"(excluding `lib`) "
    pnames :: f (HashQualified Name) -> f (Pretty ColorText)
pnames f (HashQualified Name)
hqs = Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty ColorText)
-> f (HashQualified Name) -> f (Pretty ColorText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (HashQualified Name)
hqs
    msg :: a -> Pretty ColorText
msg a
1 = Pretty ColorText
"Try " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.edit [Pretty ColorText
"1"] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to bring this into your scratch file."
    msg a
n =
      Pretty ColorText
"Try "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.edit [Pretty ColorText
"1"]
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" or "
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.edit [Pretty ColorText
"1-" Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> a -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown a
n]
        Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to bring these into your scratch file."

listDependentsOrDependencies ::
  PPE.PrettyPrintEnv ->
  Text ->
  Text ->
  Set LabeledDependency ->
  [HQ.HashQualified Name] ->
  [HQ.HashQualified Name] ->
  Pretty
listDependentsOrDependencies :: PrettyPrintEnv
-> Text
-> Text
-> Set LabeledDependency
-> [HashQualified Name]
-> [HashQualified Name]
-> Pretty ColorText
listDependentsOrDependencies PrettyPrintEnv
ppe Text
labelStart Text
label Set LabeledDependency
lds [HashQualified Name]
types [HashQualified Name]
terms =
  if [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([HashQualified Name]
types [HashQualified Name]
-> [HashQualified Name] -> [HashQualified Name]
forall a. Semigroup a => a -> a -> a
<> [HashQualified Name]
terms)
    then PrettyPrintEnv -> Set LabeledDependency -> Pretty ColorText
prettyLabeledDependencies PrettyPrintEnv
ppe Set LabeledDependency
lds Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" has no " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
label Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
"."
    else Pretty ColorText -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
Pretty s -> f (Pretty s) -> Pretty s
P.sepNonEmpty Pretty ColorText
"\n\n" [Pretty ColorText
hdr, Pretty ColorText
typesOut, Pretty ColorText
termsOut, Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip Pretty ColorText
msg]
  where
    msg :: Pretty ColorText
msg = Pretty ColorText
"Try " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.view [Pretty ColorText]
args Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to see the source of any numbered item in the above list."
    args :: [Pretty ColorText]
args = [Int -> Pretty ColorText
forall a s. (Show a, IsString s) => a -> Pretty s
P.shown ([HashQualified Name] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([HashQualified Name]
types [HashQualified Name]
-> [HashQualified Name] -> [HashQualified Name]
forall a. Semigroup a => a -> a -> a
<> [HashQualified Name]
terms))]
    hdr :: Pretty ColorText
hdr = Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text Text
labelStart Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" of: " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> PrettyPrintEnv -> Set LabeledDependency -> Pretty ColorText
prettyLabeledDependencies PrettyPrintEnv
ppe Set LabeledDependency
lds
    typesOut :: Pretty ColorText
typesOut =
      if [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
types
        then Pretty ColorText
forall a. Monoid a => a
mempty
        else
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            [ Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Types:",
              Pretty ColorText
"",
              Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
f (Pretty ColorText) -> Pretty ColorText
P.numberedList ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
c (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
types
            ]
    termsOut :: Pretty ColorText
termsOut =
      if [HashQualified Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [HashQualified Name]
terms
        then Pretty ColorText
forall a. Monoid a => a
mempty
        else
          [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
            [ Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText -> Pretty ColorText
P.bold Pretty ColorText
"Terms:",
              Pretty ColorText
"",
              Width -> Pretty ColorText -> Pretty ColorText
forall s.
(ListLike s Char, IsString s) =>
Width -> Pretty s -> Pretty s
P.indentN Width
2 (Pretty ColorText -> Pretty ColorText)
-> ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText]
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *).
Foldable f =>
Int -> f (Pretty ColorText) -> Pretty ColorText
P.numberedListFrom ([HashQualified Name] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [HashQualified Name]
types) ([Pretty ColorText] -> Pretty ColorText)
-> [Pretty ColorText] -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty (SyntaxText' TypeReference) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
c (Pretty (SyntaxText' TypeReference) -> Pretty ColorText)
-> (HashQualified Name -> Pretty (SyntaxText' TypeReference))
-> HashQualified Name
-> Pretty ColorText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashQualified Name -> Pretty (SyntaxText' TypeReference)
prettyHashQualified (HashQualified Name -> Pretty ColorText)
-> [HashQualified Name] -> [Pretty ColorText]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashQualified Name]
terms
            ]
    c :: Pretty (SyntaxText' r) -> Pretty ColorText
c = Pretty (SyntaxText' r) -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
P.syntaxToColor

displayProjectBranchReflogEntries ::
  Maybe UTCTime ->
  E.MoreEntriesThanShown ->
  [ProjectReflog.Entry Project ProjectBranch (CausalHash, ShortCausalHash)] ->
  (Pretty, NumberedArgs)
displayProjectBranchReflogEntries :: Maybe UTCTime
-> MoreEntriesThanShown
-> [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
-> (Pretty ColorText, NumberedArgs)
displayProjectBranchReflogEntries Maybe UTCTime
_ MoreEntriesThanShown
_ [] =
  (Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.warnCallout Pretty ColorText
"The reflog is empty", NumberedArgs
forall a. Monoid a => a
mempty)
displayProjectBranchReflogEntries Maybe UTCTime
mayNow MoreEntriesThanShown
_ [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
entries =
  let ([[Pretty ColorText]]
entryRows, NumberedArgs
numberedArgs) = (Entry Project ProjectBranch (CausalHash, ShortCausalHash)
 -> ([[Pretty ColorText]], NumberedArgs))
-> [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
-> ([[Pretty ColorText]], NumberedArgs)
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Entry Project ProjectBranch (CausalHash, ShortCausalHash)
-> ([[Pretty ColorText]], NumberedArgs)
renderEntry [Entry Project ProjectBranch (CausalHash, ShortCausalHash)]
entries
      rendered :: Pretty ColorText
rendered =
        [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
          [ Pretty ColorText
header,
            Pretty ColorText
"",
            [Pretty ColorText] -> [[Pretty ColorText]] -> Pretty ColorText
P.numberedColumnNHeader ([Pretty ColorText
"Branch"] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> Bool -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Monoid a => Bool -> a -> a
Monoid.whenM (Maybe UTCTime -> Bool
forall a. Maybe a -> Bool
isJust Maybe UTCTime
mayNow) [Pretty ColorText
"When"] [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText
"Hash", Pretty ColorText
"Description"]) [[Pretty ColorText]]
entryRows
          ]
   in (Pretty ColorText
rendered, NumberedArgs
numberedArgs)
  where
    header :: Pretty ColorText
header =
      [Pretty ColorText] -> Pretty ColorText
forall (f :: * -> *) s.
(Foldable f, IsString s) =>
f (Pretty s) -> Pretty s
P.lines
        [ Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
P.wrap (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$
            Pretty ColorText
"Below is a record of recent changes, you can use "
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.reset [Pretty ColorText
"#abcdef"]
              Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to reset the current branch to a previous state.",
          Pretty ColorText
"",
          Pretty ColorText -> Pretty ColorText
forall s. (ListLike s Char, IsString s) => Pretty s -> Pretty s
tip (Pretty ColorText -> Pretty ColorText)
-> Pretty ColorText -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Pretty ColorText
"Use " Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> InputPattern -> [Pretty ColorText] -> Pretty ColorText
IP.makeExample InputPattern
IP.diffNamespace [Pretty ColorText
"1", Pretty ColorText
"7"] Pretty ColorText -> Pretty ColorText -> Pretty ColorText
forall a. Semigroup a => a -> a -> a
<> Pretty ColorText
" to compare between points in history."
        ]
    renderEntry :: ProjectReflog.Entry Project ProjectBranch (CausalHash, SCH.ShortCausalHash) -> ([[Pretty]], NumberedArgs)
    renderEntry :: Entry Project ProjectBranch (CausalHash, ShortCausalHash)
-> ([[Pretty ColorText]], NumberedArgs)
renderEntry ProjectReflog.Entry {UTCTime
time :: UTCTime
$sel:time:Entry :: forall project branch causal.
Entry project branch causal -> UTCTime
time, Project
project :: Project
$sel:project:Entry :: forall project branch causal.
Entry project branch causal -> project
project, ProjectBranch
branch :: ProjectBranch
$sel:branch:Entry :: forall project branch causal. Entry project branch causal -> branch
branch, $sel:toRootCausalHash:Entry :: forall project branch causal. Entry project branch causal -> causal
toRootCausalHash = (CausalHash
toCH, ShortCausalHash
toSCH), Text
reason :: Text
$sel:reason:Entry :: forall project branch causal. Entry project branch causal -> Text
reason} =
      ( [ [ProjectAndBranch ProjectName ProjectBranchName -> Pretty ColorText
prettyProjectAndBranchName (ProjectAndBranch ProjectName ProjectBranchName
 -> Pretty ColorText)
-> ProjectAndBranch ProjectName ProjectBranchName
-> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ ProjectName
-> ProjectBranchName
-> ProjectAndBranch ProjectName ProjectBranchName
forall a b. a -> b -> ProjectAndBranch a b
ProjectAndBranch Project
project.name ProjectBranch
branch.name]
            [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> ( Maybe UTCTime
mayNow
                   Maybe UTCTime
-> (Maybe UTCTime -> [Pretty ColorText]) -> [Pretty ColorText]
forall a b. a -> (a -> b) -> b
& (UTCTime -> [Pretty ColorText])
-> Maybe UTCTime -> [Pretty ColorText]
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\UTCTime
now -> [UTCTime -> UTCTime -> Pretty ColorText
prettyHumanReadableTime UTCTime
now UTCTime
time])
               )
            [Pretty ColorText] -> [Pretty ColorText] -> [Pretty ColorText]
forall a. Semigroup a => a -> a -> a
<> [Pretty ColorText -> Pretty ColorText
P.blue (ShortCausalHash -> Pretty ColorText
forall s. IsString s => ShortCausalHash -> Pretty s
prettySCH ShortCausalHash
toSCH), Text -> Pretty ColorText
forall s. IsString s => Text -> Pretty s
P.text (Text -> Pretty ColorText) -> Text -> Pretty ColorText
forall a b. (a -> b) -> a -> b
$ Text -> Text
truncateReason Text
reason]
        ],
        [CausalHash -> StructuredArgument
SA.Namespace CausalHash
toCH]
      )
    truncateReason :: Text -> Text
    truncateReason :: Text -> Text
truncateReason Text
txt = case Int -> Text -> (Text, Text)
Text.splitAt Int
60 Text
txt of
      (Text
short, Text
"") -> Text
short
      (Text
short, Text
_) -> Text
short Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"..."