elm-in-elm/compiler/1.0.0

NOTE: the latest version is 1.0.1

Elm.Compiler.Error

All the errors the compiler can encounter.

type Error
= ParseError ParseError
| DesugarError DesugarError
| TypeError TypeError
| EmitError EmitError

The top-level error type that breaks down into specific error types.

toString : Error -> String

An English description of the error. Feel free to write your own though!

= ModuleNameDoesntMatchFilePath
{ moduleName : ModuleName
, filePath : FilePath
}
| EmptySourceDirectories
| InvalidElmJson Error
| ParseProblem (List (DeadEnd ParseContext ParseProblem))

Errors encountered during parsing from String to AST.

The DeadEnd type in this definition is the one from elm/parser.

= ExpectingPortKeyword
| ExpectingEffectKeyword
| ExpectingModuleKeyword
| ExpectingModuleName
| ExpectingExposingKeyword
| ExpectingExposingAllSymbol
| ExpectingExposingListLeftParen
| ExpectingExposingListRightParen
| ExpectingExposingListSeparatorComma
| ExpectingExposedTypeDoublePeriod
| ExpectingVarName
| ExpectingTypeOrConstructorName
| ExposingListCantBeEmpty
| ExpectingImportKeyword
| ExpectingAsKeyword
| ExpectingModuleNameWithoutDots
| ExpectingModuleNamePart
| ExpectingQualifiedVarNameDot
| ExpectingEqualsSign
| ExpectingMinusSign
| ExpectingNumber
| ExpectingSingleQuote
| ExpectingChar
| ExpectingEscapeBackslash
| ExpectingEscapeCharacter Char
| ExpectingUnicodeEscapeLeftBrace
| ExpectingUnicodeEscapeRightBrace
| InvalidUnicodeCodePoint
| ExpectingDoubleQuote
| ExpectingTripleQuote
| ExpectingPlusOperator
| ExpectingConsOperator
| ExpectingConcatOperator
| ExpectingModuleDot
| ExpectingBackslash
| ExpectingRightArrow
| ExpectingLeftParen
| ExpectingRightParen
| ExpectingLeftBracket
| ExpectingRightBracket
| ExpectingListSeparator
| ExpectingTupleSeparator
| ExpectingNotBeginningOfLine
| ExpectingIf
| ExpectingThen
| ExpectingElse
| ExpectingTrue
| ExpectingFalse
| ExpectingLet
| ExpectingIn
| ExpectingUnit
| InvalidNumber
| TriedToParseCharacterStoppingDelimiter
| CompilerBug String

The specific problem the parser encountered. Together with ParseContext and the location info this should give you enough info about what's wrong.

= InNumber
| InChar
| InCharEscapeMode
| InUnicodeCharacter
| InString
| InDoubleQuoteString
| InTripleQuoteString
| InExpr
| InIf
| InLet
| InLetBinding
| InLambda
| InList
| InUnit
| InTuple
| InTuple3

Context information about what was the parser trying to do at the time of the error. Was it trying to parse an if expression? A list? etc.

= VarNotInEnvOfModule
{ var :
{ module_ : Maybe ModuleName
, name : VarName
}
, module_ : ModuleName
}

Errors encountered during desugaring from the Frontend AST to Canonical AST.

= TypeMismatch Type Type
| OccursCheckFailed Int Type

Errors encountered during typechecking.

= MainDeclarationNotFound
| ModuleNotFoundForVar
{ module_ : ModuleName
, var : VarName
}
| ModuleNotFoundForType
{ module_ : ModuleName
, type_ : VarName
}
| DeclarationNotFound
{ module_ : ModuleName
, name : VarName
}

Errors encountered during emitting. As you're free to do the emit phase however you want, this is only returned from the helpers in Stage.Emit in the compiler CLI.

  • TODO: maybe expose Stage.Emit in this library (probably under the name Elm.Compiler.Emit or something similar)