Janiczek/elm-syntax-type-inference/1.1.0

NOTE: the latest version is 2.0.1

Elm.TypeInference.Type

A data structure representing the Elm types.

Note: This module is not named Elm.Type because that already exists in elm/project-metadata-utils.

type Type
= TypeVar String
| Function
{ from : Type
, to : Type
}
| Int
| Float
| Char
| String
| Bool
| List Type
| Unit
| Tuple2 Type Type
| Tuple3 Type Type Type
| Record { fields : Dict String Type }
| ExtensibleRecord
{ fields : Dict String Type
, extensionTypevar : String
}
| Named
{ package : PackageName
, moduleName : ModuleName
, name : String
, arguments : List Type
}
| WebGLShader
{ attributesFields : Dict String Type
, attributesExtensionTypevar : Maybe String
, uniformsFields : Dict String Type
, uniformsExtensionTypevar : Maybe String
, varyingsFields : Dict String Type
, varyingsExtensionTypevar : Maybe String
}

The inferred type.

toString : Type -> String

Display a type.

toString (Function { from = Int, to = TypeVar "a" })
--> "Int -> a"
toMultilineString : Int -> Type -> String

Display a type, breaking it to new lines when the full type is longer than maxWidth chars.

Short types stay on one line:

a -> b

Long -> chains break one arrow per line:

Foo bar baz
-> Foo bar baz
-> Foo bar baz

Long records break one field per line:

 { a : Int
 , b : String
 }
toTypeAnnotation : Type -> TypeAnnotation

Convert a Type to an elm-syntax TypeAnnotation.

All Nodes use dummy ranges.

type alias PackageName =
String

Eg. "elm/core". Comes from elm.json dependency keys.

Empty string for the user's project.

type alias VarName =
String

Eg. "foobar" in \foobar -> foobar + 1.