mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
don't export typecheckFileWithoutTNDR either
This commit is contained in:
parent
b894375345
commit
3ed4eff29c
@ -1,7 +1,6 @@
|
||||
module Unison.Cli.TypeCheck
|
||||
( ShouldUseTndr (..),
|
||||
computeTypecheckingEnvironment,
|
||||
typecheckFileWithoutTNDR,
|
||||
typecheckTerm,
|
||||
)
|
||||
where
|
||||
@ -29,16 +28,15 @@ import Unison.Var qualified as Var
|
||||
-- | Should we use type-directed name resolution?
|
||||
data ShouldUseTndr
|
||||
= ShouldUseTndr'No
|
||||
| ShouldUseTndr'Yes
|
||||
| ShouldUseTndr'Yes Parser.ParsingEnv
|
||||
|
||||
computeTypecheckingEnvironment ::
|
||||
ShouldUseTndr ->
|
||||
Codebase IO Symbol Ann ->
|
||||
[Type Symbol Ann] ->
|
||||
Parser.ParsingEnv ->
|
||||
UnisonFile Symbol Ann ->
|
||||
Sqlite.Transaction (Typechecker.Env Symbol Ann)
|
||||
computeTypecheckingEnvironment shouldUseTndr codebase ambientAbilities parsingEnv unisonFile =
|
||||
computeTypecheckingEnvironment shouldUseTndr codebase ambientAbilities unisonFile =
|
||||
case shouldUseTndr of
|
||||
ShouldUseTndr'No -> do
|
||||
typeLookup <- Codebase.typeLookupForDependencies codebase (UF.dependencies unisonFile)
|
||||
@ -48,7 +46,7 @@ computeTypecheckingEnvironment shouldUseTndr codebase ambientAbilities parsingEn
|
||||
_typeLookup = typeLookup,
|
||||
_termsByShortname = Map.empty
|
||||
}
|
||||
ShouldUseTndr'Yes ->
|
||||
ShouldUseTndr'Yes parsingEnv ->
|
||||
FileParsers.computeTypecheckingEnvironment
|
||||
ambientAbilities
|
||||
(Codebase.typeLookupForDependencies codebase)
|
||||
|
@ -1463,7 +1463,7 @@ loadUnisonFile sourceName text = do
|
||||
State.modify' (& #latestTypecheckedFile .~ Just (Left unisonFile))
|
||||
typecheckingEnv <-
|
||||
Cli.runTransaction do
|
||||
computeTypecheckingEnvironment ShouldUseTndr'Yes codebase [] parsingEnv unisonFile
|
||||
computeTypecheckingEnvironment (ShouldUseTndr'Yes parsingEnv) codebase [] unisonFile
|
||||
let Result.Result notes maybeTypecheckedUnisonFile = FileParsers.synthesizeFile typecheckingEnv unisonFile
|
||||
maybeTypecheckedUnisonFile & onNothing do
|
||||
ns <- makeShadowedPrintNamesFromHQ hqs (UF.toNames unisonFile)
|
||||
|
@ -18,7 +18,7 @@ import Unison.Cli.Monad qualified as Cli
|
||||
import Unison.Cli.MonadUtils qualified as Cli
|
||||
import Unison.Cli.NamesUtils (displayNames)
|
||||
import Unison.Cli.PrettyPrintUtils (prettyPrintEnvDecl)
|
||||
import Unison.Cli.TypeCheck (typecheckFileWithoutTNDR)
|
||||
import Unison.Cli.TypeCheck (ShouldUseTndr (..), computeTypecheckingEnvironment)
|
||||
import Unison.Codebase qualified as Codebase
|
||||
import Unison.Codebase.Branch (Branch0 (..))
|
||||
import Unison.Codebase.Branch qualified as Branch
|
||||
@ -41,6 +41,7 @@ import Unison.Codebase.Path qualified as Path
|
||||
import Unison.Codebase.TermEdit qualified as TermEdit
|
||||
import Unison.Codebase.TypeEdit qualified as TypeEdit
|
||||
import Unison.DataDeclaration (Decl)
|
||||
import Unison.FileParsers qualified as FileParsers
|
||||
import Unison.Hash (Hash)
|
||||
import Unison.Name (Name)
|
||||
import Unison.Names (Names)
|
||||
@ -511,8 +512,11 @@ getSlurpResultForUpdate requestedNames slurpCheckNames = do
|
||||
-- irrelevant, so we don't need to copy them over.
|
||||
watches = Map.empty
|
||||
}
|
||||
result <- liftIO (Codebase.runTransaction codebase (typecheckFileWithoutTNDR codebase [] unisonFile))
|
||||
case Result.result result of
|
||||
typecheckingEnv <-
|
||||
liftIO do
|
||||
Codebase.runTransaction codebase do
|
||||
computeTypecheckingEnvironment ShouldUseTndr'No codebase [] unisonFile
|
||||
case Result.result (FileParsers.synthesizeFile typecheckingEnv unisonFile) of
|
||||
Just file0 -> do
|
||||
-- Map each name generated by unhashing back to the name it should have in the Unison file we're going to
|
||||
-- typecheck.
|
||||
|
@ -14,7 +14,7 @@ import U.Codebase.Sqlite.Queries qualified as Queries
|
||||
import Unison.Cli.Monad (Cli)
|
||||
import Unison.Cli.Monad qualified as Cli
|
||||
import Unison.Cli.MonadUtils qualified as Cli
|
||||
import Unison.Cli.TypeCheck qualified as Cli (typecheckFileWithoutTNDR)
|
||||
import Unison.Cli.TypeCheck qualified as Cli (computeTypecheckingEnvironment, ShouldUseTndr (..))
|
||||
import Unison.Codebase (Codebase)
|
||||
import Unison.Codebase qualified as Codebase
|
||||
import Unison.Codebase.Branch (Branch0 (..))
|
||||
@ -62,6 +62,7 @@ import Unison.Util.Star3 qualified as Star3
|
||||
import Unison.Util.TransitiveClosure (transitiveClosure)
|
||||
import Unison.Var (Var)
|
||||
import Unison.WatchKind (WatchKind)
|
||||
import qualified Unison.FileParsers as FileParsers
|
||||
|
||||
data Edits v = Edits
|
||||
{ termEdits :: Map Reference TermEdit,
|
||||
@ -553,7 +554,8 @@ propagate patch b = case validatePatch patch of
|
||||
)
|
||||
)
|
||||
mempty
|
||||
typecheckResult <- Cli.typecheckFileWithoutTNDR codebase [] file
|
||||
typecheckingEnv <- Cli.computeTypecheckingEnvironment Cli.ShouldUseTndr'No codebase [] file
|
||||
let typecheckResult = FileParsers.synthesizeFile typecheckingEnv file
|
||||
Result.result typecheckResult
|
||||
& fmap UF.hashTerms
|
||||
& (fmap . fmap) (\(_ann, ref, wk, tm, tp) -> (ref, wk, tm, tp))
|
||||
|
@ -87,7 +87,7 @@ checkFile doc = runMaybeT $ do
|
||||
typecheckingEnv <-
|
||||
liftIO do
|
||||
Codebase.runTransaction cb do
|
||||
computeTypecheckingEnvironment ShouldUseTndr'Yes cb ambientAbilities parsingEnv parsedFile
|
||||
computeTypecheckingEnvironment (ShouldUseTndr'Yes parsingEnv) cb ambientAbilities parsedFile
|
||||
let Result.Result typecheckingNotes maybeTypecheckedFile = FileParsers.synthesizeFile typecheckingEnv parsedFile
|
||||
pure (typecheckingNotes, Just parsedFile, maybeTypecheckedFile)
|
||||
(diagnostics, codeActions) <- lift $ analyseFile fileUri srcText notes
|
||||
|
@ -338,10 +338,9 @@ typecheckSrc name src = do
|
||||
typecheckingEnv <-
|
||||
Codebase.runTransaction codebase do
|
||||
Typecheck.computeTypecheckingEnvironment
|
||||
Typecheck.ShouldUseTndr'Yes
|
||||
(Typecheck.ShouldUseTndr'Yes parsingEnv)
|
||||
codebase
|
||||
ambientAbilities
|
||||
parsingEnv
|
||||
unisonFile
|
||||
pure case FileParsers.synthesizeFile typecheckingEnv unisonFile of
|
||||
Result.Result notes Nothing -> Left (crash ("Failed to typecheck: " ++ show (Foldable.toList @Seq notes)))
|
||||
|
Loading…
Reference in New Issue
Block a user