23 lines
756 B
Haskell
23 lines
756 B
Haskell
|
|
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
|
||
|
|
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
|
||
|
|
|
||
|
|
type Result = Either Error
|