Add type information to the nodes of an elm-syntax tree.
Known types of members in a module.
Create with moduleDeclarationsToTypes
and moduleInterfaceToTypes
ModuleTypes exposed in elm/core.
Please always start with elmCoreTypes
and add further module info with FastDict.union
using moduleDeclarationsToTypes
and moduleInterfaceToTypes
And if for some reason you already know used dependencies at compile time, you can re-use the code generator used for these elm/core types
Extract all known types from declarations within a module. Un-annotated value/function declarations are ignored.
For dependency modules, use moduleInterfaceToTypes
Extract all known types
from module metadata,
usually from parsing the docs.json of a dependency.
For elm-syntax modules, use moduleDeclarationsToTypes
How to map names and symbols used in a module to their origin module.
Create with importsToModuleOriginLookup.
Contains variants, type alias names, choice type names, port names, value/function declaration names
and whether (|.) and or (|=) are imported from Parser.Advanced.
Also contains locally declared names when available.
Type- and expression/pattern-level members
are separated since you can for example have a local List variant
while also using an (implicitly) imported List type.
Calculate valid mappings of qualifications + name
to origin module based on a module's imports, see ModuleOriginLookup.
Requires all exposed ModuleTypes
so we can resolve exposing (..) and ChoiceType(..).
Like Elm.Syntax.Expression.Expression
but its sub-nodes are TypedNodes.
Be aware when trying to match references that they are split into multiple variants:
ExpressionReference (for let/module declared value/function or port or pattern variable use)ExpressionReferenceVariantExpressionReferenceRecordTypeAliasConstructorFunctionLike Elm.Syntax.Expression.LetDeclaration
but its sub-nodes are TypedNodes
Like Elm.Syntax.Pattern.Pattern
but all its sub-nodes are TypedNodes
Either decimal or hexadecimal.
Used by PatternInt and ExpressionInteger
Type information attached to expressions and patterns,
see TypedNode.
This is different from Elm.Syntax.TypeAnnotation.TypeAnnotation
in that it doesn't contain
information unrelated to type inference like ranges, qualification levels or parens.
Importantly, it also contains the overarching range of all places where each specific type variable is used. This is useful to for example find out whether a variable in a let declaration type is "forall" or inherited from the surrounding context (if the use range is fully included in the let declaration range it's forall, otherwise inherited).
Type except the variable case
If you are interested in exposing helpers like expressionMapType,
open an issue
Infer types of value/
Elm.Syntax.Expression.Functiondeclarations in a module.See
ModuleTypesandModuleOriginLookupWarning! Always first verify that provided type alias declarations aren't (mutually) recursive. Otherwise this function might never terminate.