| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Language.Egison.Type.Error
Description
This module defines type errors for the Egison type system.
Synopsis
- data TypeError
- = UnificationError Type Type TypeErrorContext
- | OccursCheckError TyVar Type TypeErrorContext
- | UnboundVariable String TypeErrorContext
- | TypeMismatch Type Type String TypeErrorContext
- | TensorShapeMismatch TensorShape TensorShape TypeErrorContext
- | TensorIndexMismatch IndexSpec IndexSpec TypeErrorContext
- | ArityMismatch Int Int TypeErrorContext
- | NotAFunction Type TypeErrorContext
- | NotATensor Type TypeErrorContext
- | AmbiguousType TyVar TypeErrorContext
- | TypeAnnotationMismatch Type Type TypeErrorContext
- | UnsupportedFeature String TypeErrorContext
- data TypeErrorContext = TypeErrorContext {}
- data TypeWarning
- data SourceLocation = SourceLocation {}
- formatTypeError :: TypeError -> String
- formatTypeWarning :: TypeWarning -> String
- emptyContext :: TypeErrorContext
- withLocation :: SourceLocation -> TypeErrorContext -> TypeErrorContext
- withExpr :: String -> TypeErrorContext -> TypeErrorContext
- withContext :: String -> TypeErrorContext -> TypeErrorContext
Documentation
Type errors
Constructors
| UnificationError Type Type TypeErrorContext | Two types could not be unified |
| OccursCheckError TyVar Type TypeErrorContext | Infinite type detected (e.g., a = [a]) |
| UnboundVariable String TypeErrorContext | Variable not found in type environment |
| TypeMismatch Type Type String TypeErrorContext | Types don't match with explanation |
| TensorShapeMismatch TensorShape TensorShape TypeErrorContext | Tensor shapes are incompatible |
| TensorIndexMismatch IndexSpec IndexSpec TypeErrorContext | Tensor indices are incompatible |
| ArityMismatch Int Int TypeErrorContext | Wrong number of arguments |
| NotAFunction Type TypeErrorContext | Tried to apply a non-function |
| NotATensor Type TypeErrorContext | Expected a tensor type |
| AmbiguousType TyVar TypeErrorContext | Could not infer a concrete type |
| TypeAnnotationMismatch Type Type TypeErrorContext | Inferred type doesn't match annotation |
| UnsupportedFeature String TypeErrorContext | Feature not yet implemented |
Instances
data TypeErrorContext Source #
Context information for where a type error occurred
Constructors
| TypeErrorContext | |
Fields
| |
Instances
| Generic TypeErrorContext Source # | |||||
Defined in Language.Egison.Type.Error Associated Types
Methods from :: TypeErrorContext -> Rep TypeErrorContext x # to :: Rep TypeErrorContext x -> TypeErrorContext # | |||||
| Show TypeErrorContext Source # | |||||
Defined in Language.Egison.Type.Error Methods showsPrec :: Int -> TypeErrorContext -> ShowS # show :: TypeErrorContext -> String # showList :: [TypeErrorContext] -> ShowS # | |||||
| Eq TypeErrorContext Source # | |||||
Defined in Language.Egison.Type.Error Methods (==) :: TypeErrorContext -> TypeErrorContext -> Bool # (/=) :: TypeErrorContext -> TypeErrorContext -> Bool # | |||||
| type Rep TypeErrorContext Source # | |||||
Defined in Language.Egison.Type.Error type Rep TypeErrorContext = D1 ('MetaData "TypeErrorContext" "Language.Egison.Type.Error" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) (C1 ('MetaCons "TypeErrorContext" 'PrefixI 'True) (S1 ('MetaSel ('Just "errorLocation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe SourceLocation)) :*: (S1 ('MetaSel ('Just "errorExpr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "errorContext") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))) | |||||
data TypeWarning Source #
Type warnings (non-fatal issues)
Constructors
| UnboundVariableWarning String TypeErrorContext | Variable not in type environment (treated as Any in permissive mode) |
| AnyTypeWarning String TypeErrorContext | Expression has |
| PartiallyTypedWarning String Type TypeErrorContext | Expression is only partially typed |
| UnsupportedExpressionWarning String TypeErrorContext | Expression type cannot be inferred (treated as Any) |
| DeprecatedFeatureWarning String TypeErrorContext | Feature is deprecated |
Instances
| Generic TypeWarning Source # | |||||
Defined in Language.Egison.Type.Error Associated Types
| |||||
| Show TypeWarning Source # | |||||
Defined in Language.Egison.Type.Error Methods showsPrec :: Int -> TypeWarning -> ShowS # show :: TypeWarning -> String # showList :: [TypeWarning] -> ShowS # | |||||
| Eq TypeWarning Source # | |||||
Defined in Language.Egison.Type.Error | |||||
| type Rep TypeWarning Source # | |||||
Defined in Language.Egison.Type.Error type Rep TypeWarning = D1 ('MetaData "TypeWarning" "Language.Egison.Type.Error" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) ((C1 ('MetaCons "UnboundVariableWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TypeErrorContext)) :+: C1 ('MetaCons "AnyTypeWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TypeErrorContext))) :+: (C1 ('MetaCons "PartiallyTypedWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TypeErrorContext))) :+: (C1 ('MetaCons "UnsupportedExpressionWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TypeErrorContext)) :+: C1 ('MetaCons "DeprecatedFeatureWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TypeErrorContext))))) | |||||
data SourceLocation Source #
Source location information
Constructors
| SourceLocation | |
Instances
| Generic SourceLocation Source # | |||||
Defined in Language.Egison.Type.Error Associated Types
Methods from :: SourceLocation -> Rep SourceLocation x # to :: Rep SourceLocation x -> SourceLocation # | |||||
| Show SourceLocation Source # | |||||
Defined in Language.Egison.Type.Error Methods showsPrec :: Int -> SourceLocation -> ShowS # show :: SourceLocation -> String # showList :: [SourceLocation] -> ShowS # | |||||
| Eq SourceLocation Source # | |||||
Defined in Language.Egison.Type.Error Methods (==) :: SourceLocation -> SourceLocation -> Bool # (/=) :: SourceLocation -> SourceLocation -> Bool # | |||||
| type Rep SourceLocation Source # | |||||
Defined in Language.Egison.Type.Error type Rep SourceLocation = D1 ('MetaData "SourceLocation" "Language.Egison.Type.Error" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) (C1 ('MetaCons "SourceLocation" 'PrefixI 'True) (S1 ('MetaSel ('Just "srcFile") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FilePath)) :*: (S1 ('MetaSel ('Just "srcLine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "srcColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int))))) | |||||
formatTypeError :: TypeError -> String Source #
Format a type error for display
formatTypeWarning :: TypeWarning -> String Source #
Format a type warning for display
emptyContext :: TypeErrorContext Source #
Empty error context
withLocation :: SourceLocation -> TypeErrorContext -> TypeErrorContext Source #
Add location to a context
withExpr :: String -> TypeErrorContext -> TypeErrorContext Source #
Add expression to a context
withContext :: String -> TypeErrorContext -> TypeErrorContext Source #
Add context message