[{"name":"Elm.TypeInference","comment":" Type inference for\n[`elm-syntax`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/)\nASTs.\n\nThe process:\n\n  - Load project and dependency data into a [`Project`](#Project) with [`init`](#init).\n  - Get a [`Type`](Elm-TypeInference-Type#Type) for a given AST\n    [`Node`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/Elm-Syntax-Node#Node)'s\n    [`Range`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/Elm-Syntax-Range#Range)\n    with [`getType`](#getType). The computed data is cached into a new version\n    of the [`Project`](#Project).\n  - Let the `Project` know about changed or deleted files with\n    [`addFile`](#addFile) and [`removeFile`](#removeFile).\n\n@docs init, empty, Project, Dependency\n\n@docs getType, getAllTypes, expand\n\n@docs addFile, removeFile\n\n","unions":[{"name":"Project","comment":" An indexed project: every file's imports are resolved, but nothing has\nbeen solved yet. Cheap to build.\n\nKeep sources up to date incrementally with [`addFile`](#addFile) and\n[`removeFile`](#removeFile).\n\n","args":[],"cases":[]}],"aliases":[{"name":"Dependency","comment":" A dependency package with its type information, parsed from the dependency's\n`elm.json` (via\n[`Elm.Project.decoder`](https://package.elm-lang.org/packages/elm/project-metadata-utils/latest/Elm-Project#decoder))\nand `docs.json` (via `elm/project-metadata-utils`\n[`Elm.Docs.decoder`](https://package.elm-lang.org/packages/elm/project-metadata-utils/latest/Elm-Docs#decoder)):\n\n  - **name:** the package identifier (e.g. `\"elm/html\"`).\n  - **dependencies:** names of the package's _immediate_ `elm.json` dependencies (eg. `\"elm/virtual-dom\"`).\n  - **modules:** the decoded `docs.json` modules.\n\n","args":[],"type":"{ name : Elm.TypeInference.Type.PackageName, dependencies : List.List Elm.TypeInference.Type.PackageName, modules : List.List Elm.Docs.Module }"}],"values":[{"name":"addFile","comment":" Make `Project` aware of a new or changed file.\n\nThe module and everything that (transitively) imports it is invalidated\nbehind the scenes and will be re-inferred lazily by [`getType`](#getType).\n\n","type":"Elm.Syntax.File.File -> Elm.TypeInference.Project -> Result.Result Elm.TypeInference.ProjectError.ProjectError Elm.TypeInference.Project"},{"name":"empty","comment":" A [`Project`](#Project) with no dependencies and no files, not even\n`elm/core`.\n\nHandy for tests and mocks. Add modules with [`addFile`](#addFile).\n\n","type":"Elm.TypeInference.Project"},{"name":"expand","comment":" Fully expand the type aliases in a [`Type`](Elm-TypeInference-Type#Type).\n\n    type alias X =\n        { a : Int, b : String }\n\n    foo : X\n    foo = { a = 5, b = \"hello\" }\n\n    -- Assuming you `getType` for the `foo`:\n    Named\n       { package = \"\"\n       , moduleName = [\"Main\"]\n       , name = \"X\"\n       , arguments = []\n       }\n\n    -- You can expand it:\n    expand project theTypeAbove\n    -->\n    Record\n        { fields =\n            Dict.fromList\n                [ ( \"a\", Int )\n                , ( \"b\", String )\n                ]\n        }\n\n","type":"Elm.TypeInference.Project -> Elm.TypeInference.Type.Type -> Elm.TypeInference.Type.Type"},{"name":"getAllTypes","comment":" Mostly a test helper.\n\nReturns [`Type`](Elm-TypeInference-Type#Type)s of all AST nodes in the project.\n\n","type":"Elm.Syntax.ModuleName.ModuleName -> Elm.TypeInference.Project -> ( Result.Result Elm.TypeInference.InferError.InferError (List.List ( Elm.Syntax.Range.Range, Elm.TypeInference.Type.Type )), Elm.TypeInference.Project )"},{"name":"getType","comment":" Get the [`Type`](Elm-TypeInference-Type#Type) for a given source\n[`Range`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/Elm-Syntax-Range#Range).\n\nThe computed data is cached into a new version of the [`Project`](#Project),\nsave it into your model to speed up future `getType` calls.\n\n","type":"Elm.Syntax.ModuleName.ModuleName -> Elm.Syntax.Range.Range -> Elm.TypeInference.Project -> ( Result.Result Elm.TypeInference.InferError.InferError Elm.TypeInference.Type.Type, Elm.TypeInference.Project )"},{"name":"init","comment":" Build a [`Project`](#Project) from dependencies and project sources.\n\n  - `directDependencies`: names of the packages listed in the project's\n    `elm.json` (e.g. `\"elm/core\"`).\n  - `allDependencies`: type information for every dependency in the closure,\n    parsed from each dependency's `elm.json` and `docs.json`.\n  - `sourcesToResolveAmbiguity`: Elm sources from dependencies' `ELM_HOME`\n    needed to disambiguate hidden types. Start with `Dict.empty`; if you get\n    `Err (NeedPackageSources needed)`, read and parse those\n    files and retry with them supplied.\n  - `projectPackageName`: the project's own package name (`Just` for packages,\n    `Nothing` for applications).\n  - `projectFiles`: the project's Elm sources.\n\n","type":"{ directDependencies : List.List Elm.TypeInference.Type.PackageName, allDependencies : List.List Elm.TypeInference.Dependency, sourcesToResolveAmbiguity : Dict.Dict Elm.TypeInference.Type.PackageName (List.List Elm.Syntax.File.File), projectPackageName : Maybe.Maybe Elm.TypeInference.Type.PackageName, projectFiles : List.List Elm.Syntax.File.File } -> Result.Result Elm.TypeInference.ProjectError.ProjectError Elm.TypeInference.Project"},{"name":"removeFile","comment":" Remove a module from a `Project`.\n\nEverything that (transitively) imported it is invalidated behind the scenes\nand will be re-inferred lazily by [`getType`](#getType).\n\n","type":"Elm.Syntax.ModuleName.ModuleName -> Elm.TypeInference.Project -> Elm.TypeInference.Project"}],"binops":[]},{"name":"Elm.TypeInference.InferError","comment":" Errors reported while resolving or inferring a module.\n\nErrors from building a `Project` (`Elm.TypeInference.init`,\n`Elm.TypeInference.addFile`) live in\n[`Elm.TypeInference.ProjectError`](Elm-TypeInference-ProjectError).\n\n@docs InferError, InferErrorDetails\n@docs toString\n\n","unions":[{"name":"InferErrorDetails","comment":" Types of errors:\n\n  - **`ImpossibleExpr`, `ImpossiblePattern` and `ImpossibleType`:** for\n    hand-crafted `elm-syntax` Files with nonsensical data, like a function call\n    without arguments or a 4-tuple. You should never be able to reach these when\n    using `elm-syntax`'s parser on real Elm files.\n\n  - **`ModuleNotFound`:** Raised when `Elm.TypeInference.getType` is called\n    with module that's not part of the indexed `Project`.\n\n  - **`RangeNotFound`:** Raised when `Elm.TypeInference.getType` is called\n    with a `Range` not corresponding to an AST node from the provided `File`s.\n\n  - **`VarNotFound`:**\n\n        module Main exposing (foo)\n\n        foo =\n            bar\n\n        --> VarNotFound\n        --    { usedIn = [ \"Main\" ]\n        --    , varName = \"bar\"\n        --    }\n\n  - **`AmbiguousName`:**\n\n        module Main exposing (foo)\n\n        import A exposing (thing)\n        import B exposing (thing)\n\n        foo =\n            thing\n\n        --> AmbiguousName\n        --    { usedIn = [ \"Main\" ]\n        --    , varName = \"thing\"\n        --    , possibleModules = [ [ \"A\" ], [ \"B\" ] ]\n        --    }\n\n  - **`AmbiguousModuleOwner`:**\n\n    Raised when two direct dependencies expose a module of the same name, eg.\n    `mdgriffith/elm-ui` and `mdgriffith/style-elements` (both expose `Element`):\n\n        module Main exposing (foo)\n\n        import Element\n\n        foo _ =\n            Element.text \"hi\"\n\n        --> AmbiguousModuleOwner\n        --    { moduleName = \"Element\"\n        --    , possiblePackages =\n        --        [ \"mdgriffith/elm-ui\"\n        --        , \"mdgriffith/style-elements\"\n        --        ]\n        --    }\n\n  - **`TypeNotFound`:**\n\n        module Main exposing (foo)\n\n        foo : Strng -> Int\n        foo _ =\n            1\n\n        --> TypeNotFound\n        --    { usedIn = [ \"Main\" ]\n        --    , qualifier = []\n        --    , typeName = \"Strng\"\n        --    }\n\n    Qualified names need the module to be imported:\n\n        module Main exposing (foo)\n\n        foo : Dict.Dict String Int -> Int\n        foo _ =\n            1\n\n        --> TypeNotFound\n        --    { usedIn = [ \"Main\" ]\n        --    , qualifier = [ \"Dict\" ]\n        --    , typeName = \"Dict\"\n        --    }\n\n    and the type to be exposed from it:\n\n        module Main exposing (foo)\n\n        import Other -- `module Other exposing (publicThing)`\n\n        foo : Other.Hidden -> Int\n        foo _ =\n            1\n\n        --> TypeNotFound\n        --    { usedIn = [ \"Main\" ]\n        --    , qualifier = [ \"Other\" ]\n        --    , typeName = \"Hidden\"\n        --    }\n\n  - **`WrongTypeArity`:**\n\n        module Main exposing (foo)\n\n        foo : Maybe Int Int -> Int\n        foo _ =\n            1\n\n        --> WrongTypeArity\n        --    { usedIn = [ \"Main\" ]\n        --    , moduleName = [ \"Maybe\" ]\n        --    , typeName = \"Maybe\"\n        --    , expected = 1\n        --    , actual = 2\n        --    }\n\n  - **`UnboundTypeVariable`:**\n\n        module Main exposing (Foo)\n\n        type alias Foo =\n            { x : a }\n\n        --> UnboundTypeVariable\n        --    { typeName = \"Foo\"\n        --    , typeVar = \"a\"\n        --    }\n\n  - **`TypeMismatch`:**\n\n        module Main exposing (foo)\n\n        foo : Int\n        foo =\n            \"abc\"\n\n        --> TypeMismatch Type.Int Type.String\n\n  - **`InfiniteType`:**\n\n        module Main exposing (foo)\n\n        foo x =\n            x x\n\n        --> InfiniteType\n        --    (Type.TypeVar \"a\")\n        --    (Type.Function\n        --      { from = Type.TypeVar \"a\"\n        --      , to = Type.TypeVar \"b\"\n        --      }\n        --    )\n\n  - **`ConstraintMismatch`:**\n\n        module Main exposing (foo)\n\n        foo x =\n            x + \"a\"\n\n        --> ConstraintMismatch\n        --    (Type.TypeVar \"number\")\n        --    Type.String\n\n  - **`RecursiveAlias`:**\n\n        module Main exposing (Comment)\n\n        type alias Comment =\n            { message : String\n            , responses : List Comment\n            }\n\n        --> RecursiveAlias\n        --    { aliases = [ { moduleName = [ \"Main\" ], name = \"Comment\" } ] }\n\n","args":[],"cases":[["ImpossibleExpr",["Elm.Syntax.Node.Node Elm.Syntax.Expression.Expression"]],["ImpossiblePattern",["Elm.Syntax.Node.Node Elm.Syntax.Pattern.Pattern"]],["ImpossibleType",["Elm.Syntax.TypeAnnotation.TypeAnnotation"]],["ModuleNotFound",[]],["RangeNotFound",[]],["VarNotFound",["{ usedIn : Elm.Syntax.ModuleName.ModuleName, varName : Elm.TypeInference.Type.VarName }"]],["AmbiguousName",["{ usedIn : Elm.Syntax.ModuleName.ModuleName, varName : Elm.TypeInference.Type.VarName, possibleModules : List.List Elm.Syntax.ModuleName.ModuleName }"]],["AmbiguousModuleOwner",["{ moduleName : String.String, possiblePackages : List.List String.String }"]],["TypeNotFound",["{ usedIn : Elm.Syntax.ModuleName.ModuleName, qualifier : Elm.Syntax.ModuleName.ModuleName, typeName : Elm.TypeInference.Type.VarName }"]],["WrongTypeArity",["{ usedIn : Elm.Syntax.ModuleName.ModuleName, moduleName : Elm.Syntax.ModuleName.ModuleName, typeName : Elm.TypeInference.Type.VarName, expected : Basics.Int, actual : Basics.Int }"]],["TypeMismatch",["Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type"]],["InfiniteType",["Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type"]],["ConstraintMismatch",["Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type"]],["RecursiveAlias",["{ aliases : List.List { moduleName : Elm.Syntax.ModuleName.ModuleName, name : Elm.TypeInference.Type.VarName } }"]],["UnboundTypeVariable",["{ typeName : Elm.TypeInference.Type.VarName, typeVar : Elm.TypeInference.Type.VarName }"]]]}],"aliases":[{"name":"InferError","comment":" A type inference error + location info.\n","args":[],"type":"{ moduleName : Elm.Syntax.ModuleName.ModuleName, declarationNames : List.List Elm.TypeInference.Type.VarName, details : Elm.TypeInference.InferError.InferErrorDetails }"}],"values":[{"name":"toString","comment":" Render an error for diagnostic output.\n","type":"Elm.TypeInference.InferError.InferError -> String.String"}],"binops":[]},{"name":"Elm.TypeInference.ProjectError","comment":" Errors reported while building a `Project` with\n`Elm.TypeInference.init` or updating it with `Elm.TypeInference.addFile`.\n\nErrors from type inference itself live in\n[`Elm.TypeInference.InferError`](Elm-TypeInference-InferError).\n\n@docs ProjectError, Location\n@docs toString\n\n","unions":[{"name":"ProjectError","comment":" Types of errors:\n\n  - **`NeedPackageSources`:** Raised by `Elm.TypeInference.init` when\n    extra dependency sources are needed to analyze whether a\n    `docs.json`-mentioned internal type is a record or a custom type.\n    Provide these files in `sourcesToResolveAmbiguity` in the next\n    `Elm.TypeInference.init` call.\n\n  - **`MissingModuleName`:** Raised when a `File` has an empty module name.\n\n  - **`DuplicateModule`:** Raised by `Elm.TypeInference.init` when two of the\n    `projectFiles` declare the same module.\n\n  - **`ImpossibleDocsType`:** for hand-crafted `docs.json` with nonsensical\n    data, like a 4-tuple. Real `docs.json` files emitted by the Elm compiler\n    should never produce these.\n\n  - **`ImpossibleType`:** Similar but for hand-crafted `elm-syntax` Files\n    given in `sourcesToResolveAmbiguity`.\n\n  - **`AmbiguousModuleOwner`:** Raised when a type in a dependency's\n    `docs.json` or sources refers to a module (`moduleName`) exposed by more\n    than one package visible to that dependency.\n\n  - **`TypeNotFound`, `WrongTypeArity`, `RecursiveAlias`:** Raised when a\n    type alias in `sourcesToResolveAmbiguity` mentions a type that can't be\n    found (eg. because the `docs.json` of the package defining it wasn't\n    provided), applies a type to the wrong number of arguments, or refers to\n    itself. The Elm compiler rejects all of these when publishing a package,\n    so they only happen with hand-written `sourcesToResolveAmbiguity` or\n    `docs.json` files, or with incomplete dependency information.\n\n","args":[],"cases":[["NeedPackageSources",["Dict.Dict Elm.TypeInference.Type.PackageName (List.List String.String)"]],["MissingModuleName",[]],["DuplicateModule",["Elm.Syntax.ModuleName.ModuleName"]],["ImpossibleDocsType",["{ location : Elm.TypeInference.ProjectError.Location, type_ : Elm.Type.Type }"]],["ImpossibleType",["{ location : Elm.TypeInference.ProjectError.Location, typeAnnotation : Elm.Syntax.TypeAnnotation.TypeAnnotation }"]],["AmbiguousModuleOwner",["{ location : Elm.TypeInference.ProjectError.Location, moduleName : String.String, possiblePackages : List.List Elm.TypeInference.Type.PackageName }"]],["TypeNotFound",["{ location : Elm.TypeInference.ProjectError.Location, qualifier : Elm.Syntax.ModuleName.ModuleName, typeName : Elm.TypeInference.Type.VarName }"]],["WrongTypeArity",["{ location : Elm.TypeInference.ProjectError.Location, moduleName : Elm.Syntax.ModuleName.ModuleName, typeName : Elm.TypeInference.Type.VarName, expected : Basics.Int, actual : Basics.Int }"]],["RecursiveAlias",["{ location : Elm.TypeInference.ProjectError.Location, aliases : List.List { moduleName : Elm.Syntax.ModuleName.ModuleName, name : Elm.TypeInference.Type.VarName } }"]]]}],"aliases":[{"name":"Location","comment":" Where in a dependency an error was found.\n","args":[],"type":"{ package : Elm.TypeInference.Type.PackageName, moduleName : Elm.Syntax.ModuleName.ModuleName, declarationName : Elm.TypeInference.Type.VarName }"}],"values":[{"name":"toString","comment":" Render an error for diagnostic output.\n","type":"Elm.TypeInference.ProjectError.ProjectError -> String.String"}],"binops":[]},{"name":"Elm.TypeInference.Type","comment":" A data structure representing the Elm types.\n\n_Note:_ This module is not named `Elm.Type` because that already exists in `elm/project-metadata-utils`.\n\n@docs Type, toString, toMultilineString, toTypeAnnotation\n@docs PackageName, VarName\n\n","unions":[{"name":"Type","comment":" The inferred type.\n","args":[],"cases":[["TypeVar",["String.String"]],["Function",["{ from : Elm.TypeInference.Type.Type, to : Elm.TypeInference.Type.Type }"]],["Int",[]],["Float",[]],["Char",[]],["String",[]],["Bool",[]],["List",["Elm.TypeInference.Type.Type"]],["Unit",[]],["Tuple2",["Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type"]],["Tuple3",["Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type","Elm.TypeInference.Type.Type"]],["Record",["{ fields : Dict.Dict String.String Elm.TypeInference.Type.Type }"]],["ExtensibleRecord",["{ fields : Dict.Dict String.String Elm.TypeInference.Type.Type, extensionTypevar : String.String }"]],["Named",["{ package : Elm.TypeInference.Type.PackageName, moduleName : Elm.Syntax.ModuleName.ModuleName, name : String.String, arguments : List.List Elm.TypeInference.Type.Type }"]],["WebGLShader",["{ attributes : Elm.TypeInference.Type.Type, uniforms : Elm.TypeInference.Type.Type, varyings : Elm.TypeInference.Type.Type }"]]]}],"aliases":[{"name":"PackageName","comment":" Eg. `\"elm/core\"`.\nComes from `elm.json` dependency keys.\n\nEmpty string for the user's project.\n\n","args":[],"type":"String.String"},{"name":"VarName","comment":" Eg. `\"foobar\"` in `\\foobar -> foobar + 1`.\n","args":[],"type":"String.String"}],"values":[{"name":"toMultilineString","comment":" Display a type, breaking it to new lines when the full type is longer than\n`maxWidth` chars.\n\nShort types stay on one line:\n\n    a -> b\n\nLong `->` chains break one arrow per line:\n\n    Foo bar baz\n    -> Foo bar baz\n    -> Foo bar baz\n\nLong records break one field per line:\n\n     { a : Int\n     , b : String\n     }\n\n","type":"Basics.Int -> Elm.TypeInference.Type.Type -> String.String"},{"name":"toString","comment":" Display a type.\n\n    toString (Function { from = Int, to = TypeVar \"a\" })\n    --> \"Int -> a\"\n\n","type":"Elm.TypeInference.Type.Type -> String.String"},{"name":"toTypeAnnotation","comment":" Convert a `Type` to an `elm-syntax` `TypeAnnotation`.\n\nAll `Node`s use dummy ranges.\n\n","type":"Elm.TypeInference.Type.Type -> Elm.Syntax.TypeAnnotation.TypeAnnotation"}],"binops":[]}]