2024-11-17 18:33:14 -08:00
|
|
|
module Errors where
|
|
|
|
|
|
|
|
|
|
import Expr
|
|
|
|
|
|
|
|
|
|
data Error
|
|
|
|
|
= SquareUntyped
|
|
|
|
|
| UnboundVariable Text
|
|
|
|
|
| NotASort Expr Expr
|
|
|
|
|
| ExpectedPiType Expr Expr
|
|
|
|
|
| NotEquivalent Expr Expr Expr
|
2024-11-20 07:37:49 -08:00
|
|
|
| PNMissingType Text
|
2024-11-22 10:36:51 -08:00
|
|
|
| DuplicateDefinition Text
|
2024-11-17 18:33:14 -08:00
|
|
|
deriving (Eq, Ord)
|
|
|
|
|
|
2024-11-22 19:44:31 -08:00
|
|
|
instance ToText Error where
|
|
|
|
|
toText SquareUntyped = "□ does not have a type"
|
|
|
|
|
toText (UnboundVariable x) = "Unbound variable: '" <> x <> "'"
|
|
|
|
|
toText (NotASort x t) = "Expected '" <> pretty x <> "' to have type * or □, instead found '" <> pretty t <> "'"
|
|
|
|
|
toText (ExpectedPiType x t) = "'" <> pretty x <> "' : '" <> pretty t <> "' is not a function"
|
|
|
|
|
toText (NotEquivalent a a' e) = "Cannot unify '" <> pretty a <> "' with '" <> pretty a' <> "' when evaluating '" <> pretty e <> "'"
|
|
|
|
|
toText (PNMissingType x) = "Axiom '" <> x <> "' missing type ascription"
|
|
|
|
|
toText (DuplicateDefinition n) = "'" <> n <> "' already defined"
|
|
|
|
|
|
|
|
|
|
instance ToString Error where
|
|
|
|
|
toString = toString . toText
|
2024-11-17 18:33:14 -08:00
|
|
|
|
|
|
|
|
type Result = Either Error
|