in update, don't bother typechecking again if we haven't changed the unison file

This commit is contained in:
Mitchell Rosen 2023-11-29 15:09:06 -05:00
parent 4ffbc7ee69
commit 011718fb8e
23 changed files with 27 additions and 109 deletions

View File

@ -128,19 +128,33 @@ handleUpdate2 = do
pure (pped, bigUf)
-- - typecheck it
Cli.respond Output.UpdateStartTypechecking
parsingEnv <- makeParsingEnv currentPath namesIncludingLibdeps
prettyParseTypecheck bigUf pped parsingEnv >>= \case
Left prettyUf -> do
Cli.Env {isTranscript} <- ask
maybePath <- if isTranscript then pure Nothing else Just . fst <$> Cli.expectLatestFile
Cli.respond (Output.DisplayDefinitionsString maybePath prettyUf)
Cli.respond Output.UpdateTypecheckingFailure
Right tuf -> do
Cli.respond Output.UpdateTypecheckingSuccess
saveTuf (findCtorNames namesExcludingLibdeps ctorNames Nothing) tuf
Cli.respond Output.Success
-- If the new-unison-file-to-typecheck is the same as old-unison-file-that-we-already-typechecked, then don't bother
-- typechecking again.
secondTuf <- do
let smallUf = UF.discardTypes tuf
let noChanges =
and
[ UF.dataDeclarations smallUf == UF.dataDeclarations bigUf,
UF.effectDeclarations smallUf == UF.effectDeclarations bigUf,
UF.terms smallUf == UF.terms bigUf, -- no need to sort these, though it wouldn't hurt
UF.watches smallUf == UF.watches bigUf
]
if noChanges
then pure tuf
else do
Cli.respond Output.UpdateStartTypechecking
parsingEnv <- makeParsingEnv currentPath namesIncludingLibdeps
secondTuf <-
prettyParseTypecheck bigUf pped parsingEnv & onLeftM \prettyUf -> do
Cli.Env {isTranscript} <- ask
maybePath <- if isTranscript then pure Nothing else Just . fst <$> Cli.expectLatestFile
Cli.respond (Output.DisplayDefinitionsString maybePath prettyUf)
Cli.returnEarly Output.UpdateTypecheckingFailure
Cli.respond Output.UpdateTypecheckingSuccess
pure secondTuf
saveTuf (findCtorNames namesExcludingLibdeps ctorNames Nothing) secondTuf
Cli.respond Output.Success
-- TODO: find a better module for this function, as it's used in a couple places
prettyParseTypecheck ::

View File

@ -140,10 +140,6 @@ Expected: `x` is now `2` and `X` is `Two`. UCM says the old definition was also
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
```

View File

@ -26,10 +26,6 @@ a = "an update"
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
```

View File

@ -72,10 +72,6 @@ Step 4: I add it and expect to see it
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.trunk> docs x

View File

@ -230,10 +230,6 @@ master.frobnicate n = n + 1
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view master.y

View File

@ -56,10 +56,6 @@ unique type a.T = T1 | T2
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
```
@ -151,10 +147,6 @@ b.termInB = 11
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
```
@ -247,10 +239,6 @@ b.termInB = 11
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.existing> move.namespace a b

View File

@ -181,10 +181,6 @@ foo/main> update
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
foo/main> reset /topic

View File

@ -51,10 +51,6 @@ foo = 200
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> names foo

View File

@ -88,10 +88,6 @@ x = 3
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.merged> view.patch

View File

@ -62,10 +62,6 @@ bar = 7
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view foo bar

View File

@ -51,10 +51,6 @@ foo = +5
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view foo

View File

@ -57,10 +57,6 @@ foo = 6
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view foo bar

View File

@ -51,10 +51,6 @@ foo = 6
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view foo

View File

@ -64,10 +64,6 @@ After updating `foo` to not be a test, we expect `view` to not render it like a
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view foo

View File

@ -46,10 +46,6 @@ unique type Foo
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo

View File

@ -43,10 +43,6 @@ unique type Foo = Bar Nat Nat
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo

View File

@ -22,10 +22,6 @@ unique type Foo = { bar : Nat }
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo

View File

@ -58,10 +58,6 @@ unique type Foo = { bar : Nat, baz : Int }
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo

View File

@ -49,10 +49,6 @@ Bug: we leave `Foo.BarAlias` in the namespace with a nameless decl.
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> find.verbose

View File

@ -46,10 +46,6 @@ unique type Foo
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo

View File

@ -35,10 +35,6 @@ Bug: this no-op update should (of course) succeed.
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
```

View File

@ -49,10 +49,6 @@ Bug: we leave `Stray.BarAlias` in the namespace with a nameless decl.
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> find.verbose

View File

@ -49,10 +49,6 @@ unique type Foo = { bar : Nat }
Okay, I'm searching the branch for code that needs to be
updated...
That's done. Now I'm making sure everything typechecks...
Everything typechecks, so I'm saving the results...
Done.
.> view Foo