Type inference for
elm-syntax
ASTs.
Optimized for lazy queries Range -> Maybe Type.
The process:
elm.json and dependencies' elm.json + docs.json into
DependencyEnv.Files
into a Project.inferModule, producing TypeLookupTable.Type
for a given AST
Node's
Range with get.Possible outcomes of running dependencyEnv.
An example NeedPackageSources:
Dict.fromList
[ ( "example/css", [ "src/Css/Internal.elm" ] ) ]Data parsed from dependencies' docs.json files.
This cache doesn't change as user's project code changes - only invalidate it
and Project when elm.json changes.
Input to dependencyEnv.
A dependency package with its type information, parsed from the dependency's
elm.json (via
Elm.Project.decoder)
and docs.json (via elm/project-metadata-utils
Elm.Docs.decoder):
"elm/html").elm.json dependencies (eg. "elm/virtual-dom").docs.json modules.Analyze the import graph of the project source code, producing a Project.
An indexed project: every file has been assigned a ModuleId and its
imports resolved, but nothing has been solved yet. Cheap to build.
Infer types in the given module.
Helper. Run inferModule for each of the given modules,
collecting successes and errors into separate Dicts.
Build a
DependencyEnv.Initially you can run with
sourcesToResolveAmbiguity = Dict.empty. If you getNeedPackageSourcesback, read and parse those Elm files from the dependencies in yourELM_HOME(usually~/.elm) and supply them insourcesToResolveAmbiguityin the next call.