Type inference for
elm-syntax
ASTs.
The process:
An indexed project: every file's imports are resolved, but nothing has been solved yet. Cheap to build.
Keep sources up to date incrementally with addFile and
removeFile.
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.Mostly a test helper.
Returns Types of all AST nodes in the project.
Fully expand the type aliases in a Type.
type alias X =
{ a : Int, b : String }
foo : X
foo = { a = 5, b = "hello" }
-- Assuming you `getType` for the `foo`:
Named
{ package = ""
, moduleName = ["Main"]
, name = "X"
, arguments = []
}
-- You can expand it:
expand project theTypeAbove
-->
Record
{ fields =
Dict.fromList
[ ( "a", Int )
, ( "b", String )
]
}Make Project aware of a new or changed file.
The module and everything that (transitively) imports it is invalidated
behind the scenes and will be re-inferred lazily by getType.
Remove a module from a Project.
Everything that (transitively) imported it is invalidated behind the scenes
and will be re-inferred lazily by getType.
Build a
Projectfrom dependencies and project sources.directDependencies: names of the packages listed in the project'selm.json(e.g."elm/core").allDependencies: type information for every dependency in the closure, parsed from each dependency'selm.jsonanddocs.json.sourcesToResolveAmbiguity: Elm sources from dependencies'ELM_HOMEneeded to disambiguate hidden types. Start withDict.empty; if you getErr (NeedPackageSources needed), read and parse those files and retry with them supplied.projectPackageName: the project's own package name (Justfor packages,Nothingfor applications).projectFiles: the project's Elm sources.