| ... |
... |
@@ -49,7 +49,7 @@ module GHC.Tc.Zonk.TcType |
|
49
|
49
|
, tidyCt, tidyEvVar, tidyDelayedError
|
|
50
|
50
|
|
|
51
|
51
|
-- ** Zonk & tidy
|
|
52
|
|
- , zonkTidyTcType, zonkTidyTcTypes
|
|
|
52
|
+ , zonkTidyTcType, zonkTidyTcTypes, zonkTidyErrCtxtMsg
|
|
53
|
53
|
, zonkTidyOrigin, zonkTidyOrigins
|
|
54
|
54
|
, zonkTidyFRRInfos
|
|
55
|
55
|
|
| ... |
... |
@@ -793,3 +793,171 @@ tidyFRROrigin env (FixedRuntimeRepOrigin ty orig) |
|
793
|
793
|
tidyEvVar :: TidyEnv -> EvVar -> EvVar
|
|
794
|
794
|
tidyEvVar env var = updateIdTypeAndMult (tidyType env) var
|
|
795
|
795
|
-- No need for tidyOpenType because all the free tyvars are already tidied
|
|
|
796
|
+
|
|
|
797
|
+
|
|
|
798
|
+
|
|
|
799
|
+{-
|
|
|
800
|
+Zonk ErrCtxtMsg
|
|
|
801
|
+-}
|
|
|
802
|
+
|
|
|
803
|
+zonkTidyErrCtxtMsg :: TidyEnv -> ErrCtxtMsg -> ZonkM (TidyEnv, ErrCtxtMsg)
|
|
|
804
|
+zonkTidyErrCtxtMsg env e@(ExprCtxt{}) = return (env, e)
|
|
|
805
|
+zonkTidyErrCtxtMsg env (ThetaCtxt ctxt theta_ty) = do
|
|
|
806
|
+ (env', theta_ty') <- zonkTidyTcTypes env theta_ty
|
|
|
807
|
+ return $ (env', ThetaCtxt ctxt theta_ty')
|
|
|
808
|
+-- zonkTidyErrCtxtMsg env (QuantifiedCtCtxt ty) = do
|
|
|
809
|
+-- (env', ty') <- zonkTidyTcTypes env ty
|
|
|
810
|
+-- return $ QuantifiedCtCtxt ty'
|
|
|
811
|
+zonkTidyErrCtxtMsg env (InferredTypeCtxt n ty) = do
|
|
|
812
|
+ (env', ty') <- zonkTidyTcType env ty
|
|
|
813
|
+ return $ (env', InferredTypeCtxt n ty')
|
|
|
814
|
+-- zonkTidyErrCtxtMsg (RecordUpdCtxt n1 n2 tys) = do
|
|
|
815
|
+-- tys' <- lift $ mapM zonkTcTypeToType tys
|
|
|
816
|
+-- return $ RecordUpdCtxt n1 n2 tys'
|
|
|
817
|
+zonkTidyErrCtxtMsg env (ClassOpCtxt n ty) = do
|
|
|
818
|
+ (env', ty') <- zonkTidyTcType env ty
|
|
|
819
|
+ return $ (env', ClassOpCtxt n ty')
|
|
|
820
|
+zonkTidyErrCtxtMsg env (MethSigCtxt n ty1 ty2) = do
|
|
|
821
|
+ (env', ty1) <- zonkTidyTcType env ty1
|
|
|
822
|
+ (env', ty2) <- zonkTidyTcType env ty2
|
|
|
823
|
+ return $ (env', MethSigCtxt n ty1 ty2)
|
|
|
824
|
+-- zonkTidyErrCtxtMsg (PatSigErrCtxt ty exp_ty) = do
|
|
|
825
|
+-- ty' <- lift $ zonkTcTypeToType ty
|
|
|
826
|
+-- exp_ty' <- lift $ readExpType_maybe exp_ty
|
|
|
827
|
+-- case exp_ty' of
|
|
|
828
|
+-- Nothing -> error "zonkTidyErrCtxtMsg PatSingErrCtxt"
|
|
|
829
|
+-- Just exp_ty' -> do
|
|
|
830
|
+-- exp_ty' <- lift $ zonkTcTypeToType exp_ty'
|
|
|
831
|
+-- return $ PatSigErrCtxt ty' exp_ty'
|
|
|
832
|
+
|
|
|
833
|
+zonkTidyErrCtxtMsg env e@(FunAppCtxt{}) = return (env, e)
|
|
|
834
|
+zonkTidyErrCtxtMsg env (FunTysCtxt ctxt ty i1 i2) = do
|
|
|
835
|
+ (env', ty') <- zonkTidyTcType env ty
|
|
|
836
|
+ return $ (env', FunTysCtxt ctxt ty' i1 i2)
|
|
|
837
|
+zonkTidyErrCtxtMsg env (FunResCtxt e i1 ty1 ty2 i2 i3) = do
|
|
|
838
|
+ (env', ty1') <- zonkTidyTcType env ty1
|
|
|
839
|
+ (env', ty2') <- zonkTidyTcType env ty2
|
|
|
840
|
+ return $ (env', FunResCtxt e i1 ty1' ty2' i2 i3)
|
|
|
841
|
+zonkTidyErrCtxtMsg env p = return (env, p)
|
|
|
842
|
+{-
|
|
|
843
|
+ -- or a type signature, or... (see 'Sig').
|
|
|
844
|
+ | SigCtxt !(Sig GhcRn)
|
|
|
845
|
+ -- | In a user-written type signature.
|
|
|
846
|
+ | UserSigCtxt !UserTypeCtxt !UserSigType
|
|
|
847
|
+
|
|
|
848
|
+ -- | In a pattern.
|
|
|
849
|
+ | PatCtxt !(Pat GhcRn)
|
|
|
850
|
+ -- | In a pattern synonym declaration.
|
|
|
851
|
+ | PatSynDeclCtxt !Name
|
|
|
852
|
+ -- | In a pattern matching context, e.g. a equation for a function binding,
|
|
|
853
|
+ -- or a case alternative, ...
|
|
|
854
|
+ | MatchCtxt !HsMatchContextRn
|
|
|
855
|
+ -- | In a match in a pattern matching context,
|
|
|
856
|
+ -- either for an expression or for an arrow command.
|
|
|
857
|
+ | forall body. (Outputable body)
|
|
|
858
|
+ => MatchInCtxt !(Match GhcRn body)
|
|
|
859
|
+ -- | In the declaration of a type constructor.
|
|
|
860
|
+ | TyConDeclCtxt !Name !(TyConFlavour TyCon)
|
|
|
861
|
+ -- | In a type or data family instance (or default instance).
|
|
|
862
|
+ | TyConInstCtxt !Name !TyConInstFlavour
|
|
|
863
|
+ -- | In the declaration of a data constructor.
|
|
|
864
|
+ | DataConDefCtxt !(NE.NonEmpty (LocatedN Name))
|
|
|
865
|
+ -- | In the result type of a data constructor.
|
|
|
866
|
+ | DataConResTyCtxt !(NE.NonEmpty (LocatedN Name))
|
|
|
867
|
+ -- | In the equations for a closed type family.
|
|
|
868
|
+ | ClosedFamEqnCtxt !TyCon
|
|
|
869
|
+ -- | In the expansion of a type synonym.
|
|
|
870
|
+ | TySynErrCtxt !TyCon
|
|
|
871
|
+ -- | In a role annotation.
|
|
|
872
|
+ | RoleAnnotErrCtxt !Name
|
|
|
873
|
+ -- | In an arrow command.
|
|
|
874
|
+ | CmdCtxt !(HsCmd GhcRn)
|
|
|
875
|
+ -- | In an instance declaration.
|
|
|
876
|
+ | InstDeclErrCtxt !(Either (LHsType GhcRn) PredType)
|
|
|
877
|
+ -- | In a default declaration.
|
|
|
878
|
+ | DefaultDeclErrCtxt { ddec_in_type_list :: !Bool }
|
|
|
879
|
+ -- | In the body of a static form.
|
|
|
880
|
+ | StaticFormCtxt !(LHsExpr GhcRn)
|
|
|
881
|
+ -- | In a pattern binding.
|
|
|
882
|
+ | forall p. OutputableBndrId p
|
|
|
883
|
+ => PatMonoBindsCtxt !(LPat (GhcPass p)) !(GRHSs GhcRn (LHsExpr GhcRn))
|
|
|
884
|
+ -- | In a foreign import/export declaration.
|
|
|
885
|
+ | ForeignDeclCtxt !(ForeignDecl GhcRn)
|
|
|
886
|
+ -- | In a record field.
|
|
|
887
|
+ | FieldCtxt !FieldLabelString
|
|
|
888
|
+ -- | In a type.
|
|
|
889
|
+ | TypeCtxt !(LHsType GhcRn)
|
|
|
890
|
+ -- | In a kind.
|
|
|
891
|
+ | KindCtxt !(LHsKind GhcRn)
|
|
|
892
|
+ -- | In an ambiguity check.
|
|
|
893
|
+ | AmbiguityCheckCtxt !UserTypeCtxt !Bool
|
|
|
894
|
+
|
|
|
895
|
+ -- | In a term-level use of a 'Name'.
|
|
|
896
|
+ | TermLevelUseCtxt !Name !TermLevelUseCtxt
|
|
|
897
|
+
|
|
|
898
|
+ -- | When checking the type of the @main@ function.
|
|
|
899
|
+ | MainCtxt !Name
|
|
|
900
|
+ -- | Warning emitted when inferring use of visible dependent quantification.
|
|
|
901
|
+ | VDQWarningCtxt !TcTyCon
|
|
|
902
|
+
|
|
|
903
|
+ -- | In a statement
|
|
|
904
|
+ | forall body.
|
|
|
905
|
+ ( Anno (StmtLR GhcRn GhcRn body) ~ SrcSpanAnnA
|
|
|
906
|
+ , Outputable body
|
|
|
907
|
+ ) => StmtErrCtxt !HsStmtContextRn !(StmtLR GhcRn GhcRn body)
|
|
|
908
|
+
|
|
|
909
|
+ -- | In a do statement.
|
|
|
910
|
+ | DoStmtErrCtxt !HsStmtContextRn !(ExprLStmt GhcRn)
|
|
|
911
|
+
|
|
|
912
|
+ -- | In patten of the do statement. (c.f. MonadFailErrors)
|
|
|
913
|
+ | StmtErrCtxtPat !HsStmtContextRn !(ExprLStmt GhcRn) (LPat GhcRn)
|
|
|
914
|
+
|
|
|
915
|
+ -- | In an rebindable syntax expression.
|
|
|
916
|
+ | SyntaxNameCtxt !(HsExpr GhcRn) !CtOrigin !TcType !SrcSpan
|
|
|
917
|
+ -- | In a RULE.
|
|
|
918
|
+ | RuleCtxt !FastString
|
|
|
919
|
+ -- | In a subtype check.
|
|
|
920
|
+ | SubTypeCtxt !TcType !TcType
|
|
|
921
|
+
|
|
|
922
|
+ -- | In an export.
|
|
|
923
|
+ | forall p. OutputableBndrId p
|
|
|
924
|
+ => ExportCtxt (IE (GhcPass p))
|
|
|
925
|
+ -- | In an export of a pattern synonym.
|
|
|
926
|
+ | PatSynExportCtxt !PatSyn
|
|
|
927
|
+ -- | In an export of a pattern synonym record field.
|
|
|
928
|
+ | PatSynRecSelExportCtxt !PatSyn !Name
|
|
|
929
|
+
|
|
|
930
|
+ -- | In an annotation.
|
|
|
931
|
+ | forall p. OutputableBndrId p
|
|
|
932
|
+ => AnnCtxt (AnnDecl (GhcPass p))
|
|
|
933
|
+
|
|
|
934
|
+ -- | In a specialise pragma.
|
|
|
935
|
+ | SpecPragmaCtxt !(Sig GhcRn)
|
|
|
936
|
+
|
|
|
937
|
+ -- | In a deriving clause.
|
|
|
938
|
+ | DerivInstCtxt !PredType
|
|
|
939
|
+ -- | In a standalone deriving clause.
|
|
|
940
|
+ | StandaloneDerivCtxt !(LHsSigWcType GhcRn)
|
|
|
941
|
+ -- | When typechecking the body of a derived instance.
|
|
|
942
|
+ | DerivBindCtxt !Id !Class ![Type]
|
|
|
943
|
+
|
|
|
944
|
+ -- | In an untyped Template Haskell quote.
|
|
|
945
|
+ | UntypedTHBracketCtxt !(HsQuote GhcPs)
|
|
|
946
|
+ -- | In a typed Template Haskell quote.
|
|
|
947
|
+ | forall p. OutputableBndrId p
|
|
|
948
|
+ => TypedTHBracketCtxt !(LHsExpr (GhcPass p))
|
|
|
949
|
+ -- | In an untyped Template Haskell splice or quasi-quote.
|
|
|
950
|
+ | UntypedSpliceCtxt !(HsUntypedSplice GhcPs)
|
|
|
951
|
+ -- | In a typed Template Haskell splice.
|
|
|
952
|
+ | forall p. OutputableBndrId p
|
|
|
953
|
+ => TypedSpliceCtxt !(Maybe SplicePointName) !(HsTypedSplice (GhcPass p))
|
|
|
954
|
+ -- | In the result of a typed Template Haskell splice.
|
|
|
955
|
+ | TypedSpliceResultCtxt !(LHsExpr GhcTc)
|
|
|
956
|
+ -- | In an argument to the Template Haskell @reifyInstances@ function.
|
|
|
957
|
+ | ReifyInstancesCtxt !TH.Name ![TH.Type]
|
|
|
958
|
+
|
|
|
959
|
+ -- | While merging Backpack signatures.
|
|
|
960
|
+ | MergeSignaturesCtxt !UnitState !ModuleName ![InstantiatedModule]
|
|
|
961
|
+ -- | While checking that a module implements a Backpack signature.
|
|
|
962
|
+ | CheckImplementsCtxt !UnitState !Module !InstantiatedModule
|
|
|
963
|
+-} |