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
showEqContext : (PrettyHL q, Show q) => Show (EqContext q n)
showEqContext = deriveShow
2023-03-13 14:33:09 -04:00
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) =
2023-02-11 12:15:50 -05:00
[("type", "ExpectedTYPE"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
toInfo (ExpectedPi _ t) =
2023-02-11 12:15:50 -05:00
[("type", "ExpectedPi"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
toInfo (ExpectedSig _ t) =
2023-02-11 12:15:50 -05:00
[("type", "ExpectedSig"),
2023-02-19 11:54:39 -05:00
("got", prettyStr True t)]
toInfo (ExpectedEnum _ t) =
[("type", "ExpectedEnum"),
("got", prettyStr True t)]
toInfo (ExpectedEq _ t) =
2023-02-11 12:15:50 -05:00
[("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") ::
[(show i, prettyStr True q) | (i, _, _, q) <- zip [1 .. length qouts] qouts]
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)]
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 (NotType _ ty) =
[("type", "NotType"),
("got", prettyStr True ty)]
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