@@ -106,70 +106,75 @@ handleUpdate2 = do
106106 Merge. checkDeclCoherency nametree numConstructors
107107 & onLeft (Cli. returnEarly . Output. IncoherentDeclDuringUpdate )
108108
109- Cli. respond Output. UpdateLookingForDependents
109+ finalOutput <-
110+ Cli. label \ done ->
111+ Cli. withRespondRegion \ respondRegion -> do
112+ respondRegion $
113+ Output. Literal (Pretty. wrap " Okay, I'm searching the branch for code that needs to be updated..." )
110114
111- (dependents, hydratedDependents) <-
112- Cli. runTransaction do
113- -- Get all dependents of things being updated
114- dependents0 <-
115- getNamespaceDependentsOf2
116- (flattenNametrees nametree)
117- (getExistingReferencesNamed termAndDeclNames (Branch. toNames currentBranch0ExcludingLibdeps))
115+ (dependents, hydratedDependents) <-
116+ Cli. runTransaction do
117+ -- Get all dependents of things being updated
118+ dependents0 <-
119+ getNamespaceDependentsOf2
120+ (flattenNametrees nametree)
121+ (getExistingReferencesNamed termAndDeclNames (Branch. toNames currentBranch0ExcludingLibdeps))
118122
119- -- Throw away the dependents that are shadowed by the file itself
120- let dependents1 :: DefnsF (Map Name ) TermReferenceId TypeReferenceId
121- dependents1 =
122- bimap
123- (`Map.withoutKeys` (Set. map Name. unsafeParseVar (UF. termNamespaceBindings tuf)))
124- (`Map.withoutKeys` (Set. map Name. unsafeParseVar (UF. typeNamespaceBindings tuf)))
125- dependents0
123+ -- Throw away the dependents that are shadowed by the file itself
124+ let dependents1 :: DefnsF (Map Name ) TermReferenceId TypeReferenceId
125+ dependents1 =
126+ bimap
127+ (`Map.withoutKeys` (Set. map Name. unsafeParseVar (UF. termNamespaceBindings tuf)))
128+ (`Map.withoutKeys` (Set. map Name. unsafeParseVar (UF. typeNamespaceBindings tuf)))
129+ dependents0
126130
127- -- Hydrate the dependents for rendering
128- hydratedDependents <-
129- hydrateDefns
130- (Codebase. unsafeGetTermComponent env. codebase)
131- Operations. expectDeclComponent
132- dependents1
131+ -- Hydrate the dependents for rendering
132+ hydratedDependents <-
133+ hydrateDefns
134+ (Codebase. unsafeGetTermComponent env. codebase)
135+ Operations. expectDeclComponent
136+ dependents1
133137
134- pure (dependents1, hydratedDependents)
138+ pure (dependents1, hydratedDependents)
135139
136- secondTuf <- do
137- case defnsAreEmpty dependents of
138- -- If there are no dependents of the updates, then just use the already-typechecked file.
139- True -> pure tuf
140- False -> do
141- Cli. respond Output. UpdateStartTypechecking
140+ secondTuf <- do
141+ case defnsAreEmpty dependents of
142+ -- If there are no dependents of the updates, then just use the already-typechecked file.
143+ True -> pure tuf
144+ False -> do
145+ respondRegion ( Output. Literal ( Pretty. wrap " That's done. Now I'm making sure everything typechecks... " ))
142146
143- let prettyUnisonFile =
144- let ppe = makePPE 10 namesIncludingLibdeps (UF. typecheckedToNames tuf) dependents
145- in makePrettyUnisonFile
146- (Pretty. prettyUnisonFile ppe (UF. discardTypes tuf))
147- (renderDefnsForUnisonFile declNameLookup ppe (over (# terms . mapped) snd hydratedDependents))
147+ let prettyUnisonFile =
148+ let ppe = makePPE 10 namesIncludingLibdeps (UF. typecheckedToNames tuf) dependents
149+ in makePrettyUnisonFile
150+ (Pretty. prettyUnisonFile ppe (UF. discardTypes tuf))
151+ (renderDefnsForUnisonFile declNameLookup ppe (over (# terms . mapped) snd hydratedDependents))
148152
149- parsingEnv <- Cli. makeParsingEnv pp namesIncludingLibdeps
153+ parsingEnv <- Cli. makeParsingEnv pp namesIncludingLibdeps
150154
151- secondTuf <-
152- parseAndTypecheck prettyUnisonFile parsingEnv & onNothingM do
153- scratchFilePath <- fst <$> Cli. expectLatestFile
154- liftIO $ env. writeSource (Text. pack scratchFilePath) (Text. pack $ Pretty. toPlain 80 prettyUnisonFile) True
155- Cli. returnEarly Output. UpdateTypecheckingFailure
155+ secondTuf <-
156+ parseAndTypecheck prettyUnisonFile parsingEnv & onNothingM do
157+ scratchFilePath <- fst <$> Cli. expectLatestFile
158+ liftIO $ env. writeSource (Text. pack scratchFilePath) (Text. pack $ Pretty. toPlain 80 prettyUnisonFile) True
159+ done Output. UpdateTypecheckingFailure
156160
157- Cli. respond Output. UpdateTypecheckingSuccess
161+ respondRegion ( Output. Literal ( Pretty. wrap " Everything typechecks, so I'm saving the results... " ))
158162
159- pure secondTuf
163+ pure secondTuf
160164
161- path <- Cli. getCurrentProjectPath
162- branchUpdates <-
163- Cli. runTransactionWithRollback \ abort -> do
164- Codebase. addDefsToCodebase env. codebase secondTuf
165- typecheckedUnisonFileToBranchUpdates
166- abort
167- (\ typeName -> Right (Map. lookup typeName declNameLookup. declToConstructors))
168- secondTuf
169- Cli. stepAt " update" (path, Branch. batchUpdates branchUpdates)
170- # latestTypecheckedFile .= Nothing
165+ path <- Cli. getCurrentProjectPath
166+ branchUpdates <-
167+ Cli. runTransactionWithRollback \ abort -> do
168+ Codebase. addDefsToCodebase env. codebase secondTuf
169+ typecheckedUnisonFileToBranchUpdates
170+ abort
171+ (\ typeName -> Right (Map. lookup typeName declNameLookup. declToConstructors))
172+ secondTuf
173+ Cli. stepAt " update" (path, Branch. batchUpdates branchUpdates)
174+ # latestTypecheckedFile .= Nothing
175+ pure Output. Success
171176
172- Cli. respond Output. Success
177+ Cli. respond finalOutput
173178
174179makePrettyUnisonFile :: Pretty ColorText -> DefnsF (Map Name ) (Pretty ColorText ) (Pretty ColorText ) -> Pretty ColorText
175180makePrettyUnisonFile originalFile dependents =
0 commit comments