module Errors where import Data.Text (Text) import qualified Data.Text as T import Expr data Error = SquareUntyped | UnboundVariable Text | NotASort Expr Expr | ExpectedPiType Expr Expr | NotEquivalent Expr Expr Expr | PNMissingType Text | DuplicateDefinition Text deriving (Eq, Ord) instance Show Error where show SquareUntyped = "□ does not have a type" show (UnboundVariable x) = "Unbound variable: '" ++ T.unpack x ++ "'" show (NotASort x t) = "Expected '" ++ prettyS x ++ "' to have type * or □, instead found '" ++ prettyS t ++ "'" show (ExpectedPiType x t) = "'" ++ prettyS x ++ "' : '" ++ prettyS t ++ "' is not a function" show (NotEquivalent a a' e) = "Cannot unify '" ++ prettyS a ++ "' with '" ++ prettyS a' ++ "' when evaluating '" ++ prettyS e ++ "'" show (PNMissingType x) = "Axiom '" ++ T.unpack x ++ "' missing type ascription" show (DuplicateDefinition n) = "'" ++ T.unpack n ++ "' already defined" type Result = Either Error