pretty printing errors

This commit is contained in:
rhiannon morris 2023-03-15 15:54:51 +01:00
parent 54ba4e237f
commit 32f38238ef
14 changed files with 424 additions and 217 deletions

View file

@ -33,76 +33,5 @@ ToInfo WhnfError where
("list", show ts)]
export
PrettyHL q => ToInfo (Error q) where
toInfo (NotInScope x) =
[("type", "NotInScope"),
("name", show x)]
toInfo (ExpectedTYPE _ t) =
[("type", "ExpectedTYPE"),
("got", prettyStr True t)]
toInfo (ExpectedPi _ t) =
[("type", "ExpectedPi"),
("got", prettyStr True t)]
toInfo (ExpectedSig _ t) =
[("type", "ExpectedSig"),
("got", prettyStr True t)]
toInfo (ExpectedEnum _ t) =
[("type", "ExpectedEnum"),
("got", prettyStr True t)]
toInfo (ExpectedEq _ t) =
[("type", "ExpectedEq"),
("got", prettyStr True t)]
toInfo (BadUniverse k l) =
[("type", "BadUniverse"),
("low", show k),
("high", show l)]
toInfo (TagNotIn t ts) =
[("type", "TagNotIn"),
("tag", show t),
("set", show $ SortedSet.toList ts)]
toInfo (BadCaseQtys _ qouts) =
("type", "BadCaseQtys") ::
[(show i, prettyStr True q) | (i, _, _, q) <- zip [1 .. length qouts] qouts]
toInfo (ClashT _ mode ty s t) =
[("type", "ClashT"),
("mode", show mode),
("ty", prettyStr True ty),
("left", prettyStr True s),
("right", prettyStr True t)]
toInfo (ClashTy _ mode s t) =
[("type", "ClashTy"),
("mode", show mode),
("left", prettyStr True s),
("right", prettyStr True t)]
toInfo (ClashE _ mode e f) =
[("type", "ClashE"),
("mode", show mode),
("left", prettyStr True e),
("right", prettyStr True f)]
toInfo (ClashU mode k l) =
[("type", "ClashU"),
("mode", show mode),
("left", show k),
("right", show l)]
toInfo (ClashQ pi rh) =
[("type", "ClashQ"),
("left", prettyStr True pi),
("right", prettyStr True rh)]
toInfo (NotType _ ty) =
[("type", "NotType"),
("got", prettyStr True ty)]
toInfo (WrongType _ ty s t) =
[("type", "WrongType"),
("ty", prettyStr True ty),
("left", prettyStr True s),
("right", prettyStr True t)]
-- [todo] add nested yamls to TAP and include context here
toInfo (WhileChecking _ _ _ _ err) = toInfo err
toInfo (WhileCheckingTy _ _ _ err) = toInfo err
toInfo (WhileInferring _ _ _ err) = toInfo err
toInfo (WhileComparingT _ _ _ _ _ err) = toInfo err
toInfo (WhileComparingE _ _ _ _ err) = toInfo err
toInfo (WhnfError err) = toInfo err
(Eq q, PrettyHL q) => ToInfo (Error q) where
toInfo err = [("err", show $ prettyError True True err)]