| ... |
... |
@@ -85,7 +85,6 @@ import GHC.Types.Unique.Supply |
|
85
|
85
|
|
|
86
|
86
|
import qualified Data.Kind as Hs
|
|
87
|
87
|
import Data.List.NonEmpty (NonEmpty (..))
|
|
88
|
|
-import qualified Data.List.NonEmpty as NE
|
|
89
|
88
|
|
|
90
|
89
|
{- *********************************************************************
|
|
91
|
90
|
* *
|
| ... |
... |
@@ -655,6 +654,8 @@ data CtOrigin |
|
655
|
654
|
|
|
656
|
655
|
| ExpansionOrigin SrcCodeOrigin -- This is due to an expansion of the original thing given by SrcCodeOrigin
|
|
657
|
656
|
|
|
|
657
|
+ | ExpectedTySyntax !CtOrigin (HsExpr GhcRn)
|
|
|
658
|
+
|
|
658
|
659
|
-- | A rebindable syntax operator is expected to have a function type.
|
|
659
|
660
|
--
|
|
660
|
661
|
-- Test cases for representation-polymorphism checks:
|
| ... |
... |
@@ -679,8 +680,6 @@ data CtOrigin |
|
679
|
680
|
-- RepPolyApp
|
|
680
|
681
|
| forall (p :: Pass)
|
|
681
|
682
|
. Outputable (HsExpr (GhcPass p)) => ExpectedFunTyArg
|
|
682
|
|
- Int
|
|
683
|
|
- -- ^ Argument number
|
|
684
|
683
|
!TypedThing
|
|
685
|
684
|
-- ^ function
|
|
686
|
685
|
!(HsExpr (GhcPass p))
|
| ... |
... |
@@ -708,7 +707,6 @@ data CtOrigin |
|
708
|
707
|
updatePositionCtOrigin :: Int -> CtOrigin -> CtOrigin
|
|
709
|
708
|
updatePositionCtOrigin i (ExpectedFunTySyntaxOp _ c e) = ExpectedFunTySyntaxOp i c e
|
|
710
|
709
|
updatePositionCtOrigin i (ExpectedFunTyViewPat _ e) = ExpectedFunTyViewPat i e
|
|
711
|
|
-updatePositionCtOrigin i (ExpectedFunTyArg _ t e) = ExpectedFunTyArg i t e
|
|
712
|
710
|
updatePositionCtOrigin i (ExpectedFunTyMatches _ t e) = ExpectedFunTyMatches i t e
|
|
713
|
711
|
updatePositionCtOrigin _ c = c
|
|
714
|
712
|
|
| ... |
... |
@@ -809,7 +807,7 @@ exprCtOrigin (HsMultiIf _ rhs) = lGRHSCtOrigin rhs |
|
809
|
807
|
exprCtOrigin (HsLet _ _ e) = lexprCtOrigin e
|
|
810
|
808
|
exprCtOrigin (HsDo {}) = DoStmtOrigin
|
|
811
|
809
|
exprCtOrigin (RecordCon {}) = Shouldn'tHappenOrigin "record construction"
|
|
812
|
|
-exprCtOrigin (RecordUpd {}) = RecordUpdOrigin
|
|
|
810
|
+exprCtOrigin (RecordUpd{}) = RecordUpdOrigin
|
|
813
|
811
|
exprCtOrigin (ExprWithTySig {}) = ExprSigOrigin
|
|
814
|
812
|
exprCtOrigin (ArithSeq {}) = Shouldn'tHappenOrigin "arithmetic sequence"
|
|
815
|
813
|
exprCtOrigin (HsPragE _ _ e) = lexprCtOrigin e
|
| ... |
... |
@@ -858,11 +856,20 @@ pprCtOrigin (GivenOrigin sk) |
|
858
|
856
|
|
|
859
|
857
|
pprCtOrigin (ExpansionOrigin o)
|
|
860
|
858
|
= ctoHerald <+> what
|
|
861
|
|
- where what :: SDoc
|
|
862
|
|
- what = case o of
|
|
863
|
|
- OrigStmt{} -> text "a do statement"
|
|
864
|
|
- OrigExpr e -> pprCtO (exprCtOrigin e)
|
|
865
|
|
- OrigPat p -> text "a pattern" <+> ppr p
|
|
|
859
|
+ where
|
|
|
860
|
+ what :: SDoc
|
|
|
861
|
+ what = case o of
|
|
|
862
|
+ OrigStmt{} ->
|
|
|
863
|
+ text "a do statement"
|
|
|
864
|
+ OrigPat p ->
|
|
|
865
|
+ text "a do statement" $$
|
|
|
866
|
+ text "with the failable pattern" <+> quotes (ppr p)
|
|
|
867
|
+ OrigExpr (HsGetField _ _ (L _ f)) ->
|
|
|
868
|
+ hsep [text "selecting the field", quotes (ppr f)]
|
|
|
869
|
+ OrigExpr (HsOverLabel _ l) ->
|
|
|
870
|
+ hsep [text "the overloaded label" ,quotes (char '#' <> ppr l)]
|
|
|
871
|
+ OrigExpr e@(RecordUpd{}) -> hsep [text "a record update" <+> quotes (ppr e) ]
|
|
|
872
|
+ OrigExpr e -> text "the expression" <+> (ppr e)
|
|
866
|
873
|
|
|
867
|
874
|
pprCtOrigin (GivenSCOrigin sk d blk)
|
|
868
|
875
|
= vcat [ ctoHerald <+> pprSkolInfo sk
|
| ... |
... |
@@ -976,16 +983,21 @@ pprCtOrigin (NonLinearPatternOrigin reason pat) |
|
976
|
983
|
= hang (ctoHerald <+> text "a non-linear pattern" <+> quotes (ppr pat))
|
|
977
|
984
|
2 (pprNonLinearPatternReason reason)
|
|
978
|
985
|
|
|
|
986
|
+pprCtOrigin (ExpectedTySyntax orig arg)
|
|
|
987
|
+ = vcat [ text "The expression" <+> quotes (ppr arg)
|
|
|
988
|
+ , nest 2 (ppr orig) ]
|
|
|
989
|
+
|
|
979
|
990
|
pprCtOrigin (ExpectedFunTySyntaxOp i orig op) =
|
|
980
|
991
|
vcat [ sep [ the_arg_of i
|
|
981
|
992
|
, text "the rebindable syntax operator"
|
|
982
|
993
|
, quotes (ppr op) ]
|
|
983
|
994
|
, nest 2 (ppr orig) ]
|
|
|
995
|
+
|
|
984
|
996
|
pprCtOrigin (ExpectedFunTyViewPat i expr) =
|
|
985
|
997
|
vcat [ the_arg_of i <+> text "the view pattern"
|
|
986
|
998
|
, nest 2 (ppr expr) ]
|
|
987
|
|
-pprCtOrigin (ExpectedFunTyArg i fun arg) =
|
|
988
|
|
- sep [ text "The" <+> speakNth i <+> text "argument"
|
|
|
999
|
+pprCtOrigin (ExpectedFunTyArg fun arg) =
|
|
|
1000
|
+ sep [ text "The argument"
|
|
989
|
1001
|
, quotes (ppr arg)
|
|
990
|
1002
|
, text "of"
|
|
991
|
1003
|
, quotes (ppr fun) ]
|
| ... |
... |
@@ -1076,10 +1088,10 @@ pprCtO (InstanceSigOrigin {}) = text "a type signature in an instance" |
|
1076
|
1088
|
pprCtO (AmbiguityCheckOrigin {}) = text "a type ambiguity check"
|
|
1077
|
1089
|
pprCtO (ImpedanceMatching {}) = text "combining required constraints"
|
|
1078
|
1090
|
pprCtO (NonLinearPatternOrigin _ pat) = hsep [text "a non-linear pattern" <+> quotes (ppr pat)]
|
|
1079
|
|
-pprCtO (ExpansionOrigin (OrigPat p)) = hsep [text "a pattern" <+> quotes (ppr p)]
|
|
1080
|
|
-pprCtO (ExpansionOrigin (OrigStmt{})) = text "a do statement"
|
|
1081
|
|
-pprCtO (ExpansionOrigin (OrigExpr (HsGetField _ _ (L _ f)))) = hsep [text "selecting the field", quotes (ppr f)]
|
|
1082
|
1091
|
pprCtO (ExpansionOrigin (OrigExpr e)) = text "an expression" <+> ppr e
|
|
|
1092
|
+pprCtO (ExpansionOrigin (OrigStmt{})) = text "a do statement"
|
|
|
1093
|
+pprCtO (ExpansionOrigin (OrigPat{})) = text "a pattern"
|
|
|
1094
|
+pprCtO (ExpectedTySyntax o _) = pprCtO o
|
|
1083
|
1095
|
pprCtO (ExpectedFunTySyntaxOp{}) = text "a rebindable syntax operator"
|
|
1084
|
1096
|
pprCtO (ExpectedFunTyViewPat{}) = text "a view pattern"
|
|
1085
|
1097
|
pprCtO (ExpectedFunTyArg{}) = text "a funtion head"
|
| ... |
... |
@@ -1298,7 +1310,7 @@ data FixedRuntimeRepContext |
|
1298
|
1310
|
--
|
|
1299
|
1311
|
-- See 'ExpectedFunTyOrigin' for more details.
|
|
1300
|
1312
|
| FRRExpectedFunTy
|
|
1301
|
|
- !CtOrigin -- !ExpectedFunTyOrigin
|
|
|
1313
|
+ !CtOrigin
|
|
1302
|
1314
|
!Int
|
|
1303
|
1315
|
-- ^ argument position (1-indexed)
|
|
1304
|
1316
|
|
| ... |
... |
@@ -1540,7 +1552,7 @@ pprExpectedFunTyHerald (ExpectedFunTySyntaxOp {}) |
|
1540
|
1552
|
= text "This rebindable syntax expects a function with"
|
|
1541
|
1553
|
pprExpectedFunTyHerald (ExpectedFunTyViewPat {})
|
|
1542
|
1554
|
= text "A view pattern expression expects"
|
|
1543
|
|
-pprExpectedFunTyHerald (ExpectedFunTyArg _ fun _)
|
|
|
1555
|
+pprExpectedFunTyHerald (ExpectedFunTyArg fun _)
|
|
1544
|
1556
|
= sep [ text "The function" <+> quotes (ppr fun)
|
|
1545
|
1557
|
, text "is applied to" ]
|
|
1546
|
1558
|
pprExpectedFunTyHerald (ExpectedFunTyMatches _ fun (MG { mg_alts = L _ alts }))
|