dhall-1.4.0: A configuration language guaranteed to terminate

Safe HaskellNone
LanguageHaskell98

Dhall.TypeCheck

Contents

Description

This module contains the logic for type checking Dhall code

Synopsis

Type-checking

typeWith :: Context (Expr s X) -> Expr s X -> Either (TypeError s) (Expr s X) Source #

Type-check an expression and return the expression's type if type-checking succeeds or an error if type-checking fails

typeWith does not necessarily normalize the type since full normalization is not necessary for just type-checking. If you actually care about the returned type then you may want to normalize it afterwards.

typeOf :: Expr s X -> Either (TypeError s) (Expr s X) Source #

typeOf is the same as typeWith with an empty context, meaning that the expression must be closed (i.e. no free variables), otherwise type-checking will fail.

Types

newtype X Source #

Like Void, except with a shorter inferred type

Constructors

X 

Fields

Instances

Eq X Source # 

Methods

(==) :: X -> X -> Bool #

(/=) :: X -> X -> Bool #

Show X Source # 

Methods

showsPrec :: Int -> X -> ShowS #

show :: X -> String #

showList :: [X] -> ShowS #

Buildable X Source # 

Methods

build :: X -> Builder #

data TypeError s Source #

A structured type error that includes context

Constructors

TypeError 

newtype DetailedTypeError s Source #

Newtype used to wrap error messages so that they render with a more detailed explanation of what went wrong

Constructors

DetailedTypeError (TypeError s) 

data TypeMessage s Source #

The specific type error

Constructors

UnboundVariable 
InvalidInputType (Expr s X) 
InvalidOutputType (Expr s X) 
NotAFunction (Expr s X) (Expr s X) 
TypeMismatch (Expr s X) (Expr s X) (Expr s X) (Expr s X) 
AnnotMismatch (Expr s X) (Expr s X) (Expr s X) 
Untyped 
MissingListType 
MismatchedListElements Int (Expr s X) (Expr s X) (Expr s X) 
InvalidListElement Int (Expr s X) (Expr s X) (Expr s X) 
InvalidListType (Expr s X) 
InvalidOptionalElement (Expr s X) (Expr s X) (Expr s X) 
InvalidOptionalLiteral Int 
InvalidOptionalType (Expr s X) 
InvalidPredicate (Expr s X) (Expr s X) 
IfBranchMismatch (Expr s X) (Expr s X) (Expr s X) (Expr s X) 
IfBranchMustBeTerm Bool (Expr s X) (Expr s X) (Expr s X) 
InvalidField Text (Expr s X) 
InvalidFieldType Text (Expr s X) 
InvalidAlternative Text (Expr s X) 
InvalidAlternativeType Text (Expr s X) 
DuplicateAlternative Text 
MustCombineARecord Char (Expr s X) (Expr s X) 
FieldCollision Text 
MustMergeARecord (Expr s X) (Expr s X) 
MustMergeUnion (Expr s X) (Expr s X) 
UnusedHandler (Set Text) 
MissingHandler (Set Text) 
HandlerInputTypeMismatch Text (Expr s X) (Expr s X) 
HandlerOutputTypeMismatch Text (Expr s X) Text (Expr s X) 
InvalidHandlerOutputType Text (Expr s X) (Expr s X) 
MissingMergeType 
HandlerNotAFunction Text (Expr s X) 
NotARecord Text (Expr s X) (Expr s X) 
MissingField Text (Expr s X) 
CantAnd (Expr s X) (Expr s X) 
CantOr (Expr s X) (Expr s X) 
CantEQ (Expr s X) (Expr s X) 
CantNE (Expr s X) (Expr s X) 
CantTextAppend (Expr s X) (Expr s X) 
CantAdd (Expr s X) (Expr s X) 
CantMultiply (Expr s X) (Expr s X) 
NoDependentLet (Expr s X) (Expr s X) 
NoDependentTypes (Expr s X) (Expr s X) 

Instances