quox/tests/TypingImpls.idr

109 lines
2.9 KiB
Idris
Raw Normal View History

2023-02-11 12:15:50 -05:00
module TypingImpls
import TAP
import public Quox.Typing
import public Quox.Pretty
2023-03-13 14:33:09 -04:00
import public TermImpls
2023-02-11 12:15:50 -05:00
2023-03-13 14:33:09 -04:00
import Derive.Prelude
%language ElabReflection
2023-03-13 14:39:29 -04:00
%runElab derive "Reduce.WhnfError" [Show]
2023-03-13 14:33:09 -04:00
%runElab deriveIndexed "DimEq" [Show]
export %hint
showTyContext : (PrettyHL q, Show q) => Show (TyContext q d n)
showTyContext = deriveShow
export %hint
showTypingError : (PrettyHL q, Show q) => Show (Error q)
showTypingError = deriveShow
export
2023-03-13 14:39:29 -04:00
ToInfo WhnfError where
toInfo (MissingEnumArm t ts) =
[("type", "MissingEnumArm"),
("tag", show t),
("list", show ts)]
2023-02-11 12:15:50 -05:00
export
PrettyHL q => ToInfo (Error q) where
toInfo (NotInScope x) =
[("type", "NotInScope"),
("name", show x)]
toInfo (ExpectedTYPE t) =
[("type", "ExpectedTYPE"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
2023-02-11 12:15:50 -05:00
toInfo (ExpectedPi t) =
[("type", "ExpectedPi"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
2023-02-11 12:15:50 -05:00
toInfo (ExpectedSig t) =
[("type", "ExpectedSig"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
toInfo (ExpectedEnum t) =
[("type", "ExpectedEnum"),
("got", prettyStr True t)]
2023-02-11 12:15:50 -05:00
toInfo (ExpectedEq t) =
[("type", "ExpectedEq"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
2023-02-11 12:15:50 -05:00
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") ::
2023-03-13 14:31:52 -04:00
[(show i, prettyStr True q) | (i, q) <- zip [1 .. length qouts] qouts]
2023-02-11 12:15:50 -05:00
toInfo (ClashT mode ty s t) =
2023-02-19 11:54:39 -05:00
[("type", "ClashT"),
2023-02-11 12:15:50 -05:00
("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)]
2023-02-11 12:15:50 -05:00
toInfo (ClashE mode e f) =
2023-02-19 11:54:39 -05:00
[("type", "ClashE"),
2023-02-11 12:15:50 -05:00
("mode", show mode),
("left", prettyStr True e),
("right", prettyStr True f)]
toInfo (ClashU mode k l) =
2023-02-19 11:54:39 -05:00
[("type", "ClashU"),
2023-02-11 12:15:50 -05:00
("mode", show mode),
2023-03-05 10:48:29 -05:00
("left", show k),
("right", show l)]
2023-02-11 12:15:50 -05:00
toInfo (ClashQ pi rh) =
2023-02-19 11:54:39 -05:00
[("type", "ClashQ"),
2023-02-11 12:15:50 -05:00
("left", prettyStr True pi),
("right", prettyStr True rh)]
toInfo (ClashD p q) =
2023-02-19 11:54:39 -05:00
[("type", "ClashD"),
2023-02-11 12:15:50 -05:00
("left", prettyStr True p),
("right", prettyStr True q)]
toInfo (NotType ty) =
[("type", "NotType"),
("got", prettyStr True ty)]
2023-02-11 12:15:50 -05:00
toInfo (WrongType ty s t) =
2023-02-19 11:54:39 -05:00
[("type", "WrongType"),
2023-02-11 12:15:50 -05:00
("ty", prettyStr True ty),
("left", prettyStr True s),
("right", prettyStr True t)]
2023-02-19 11:54:39 -05:00
-- [todo] add nested yamls to TAP and include context here
toInfo (WhileChecking _ _ _ _ err) = toInfo err
toInfo (WhileCheckingTy _ _ _ err) = toInfo err
2023-02-19 11:54:39 -05:00
toInfo (WhileInferring _ _ _ err) = toInfo err
toInfo (WhileComparingT _ _ _ _ _ err) = toInfo err
toInfo (WhileComparingE _ _ _ _ err) = toInfo err
toInfo (WhnfError err) = toInfo err