Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • compiler/GHC/Tc/Gen/App.hs
    ... ... @@ -857,7 +857,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
    857 857
         -- Rule IARG from Fig 4 of the QL paper:
    
    858 858
         go1 pos acc fun_ty
    
    859 859
             (EValArg { ea_arg = arg, ea_ctxt = ctxt } : rest_args)
    
    860
    -      = do { let herald = ExpectedFunTyArg pos (HsExprTcThing tc_fun) (unLoc arg)
    
    860
    +      = do { let herald = mk_herald tc_fun (unLoc arg)
    
    861 861
                ; (wrap, arg_ty, res_ty) <-
    
    862 862
                     -- NB: matchActualFunTy does the rep-poly check.
    
    863 863
                     -- For example, suppose we have f :: forall r (a::TYPE r). a -> Int
    
    ... ... @@ -876,7 +876,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
    876 876
         -- Make a fresh nus for each argument in rule IVAR
    
    877 877
         new_arg_ty (L _ arg) i
    
    878 878
           = do { arg_nu <- newOpenFlexiFRRTyVarTy $
    
    879
    -                       FRRExpectedFunTy (ExpectedFunTyArg i (HsExprTcThing tc_fun) arg) i
    
    879
    +                       FRRExpectedFunTy (mk_herald tc_fun arg) i
    
    880 880
                    -- Following matchActualFunTy, we create nu_i :: TYPE kappa_i[conc],
    
    881 881
                    -- thereby ensuring that the arguments have concrete runtime representations
    
    882 882
     
    
    ... ... @@ -886,6 +886,12 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
    886 886
     
    
    887 887
                ; return (mkScaled mult_ty arg_nu) }
    
    888 888
     
    
    889
    +    mk_herald :: HsExpr GhcTc -> HsExpr GhcRn -> CtOrigin
    
    890
    +    mk_herald tc_fun arg
    
    891
    +      = case fun_orig of
    
    892
    +           ExpansionOrigin (OrigStmt{}) -> ExpectedTySyntax DoStmtOrigin arg
    
    893
    +           _ -> ExpectedFunTyArg (HsExprTcThing tc_fun) arg
    
    894
    +
    
    889 895
     -- Is the argument supposed to instantiate a forall?
    
    890 896
     --
    
    891 897
     -- In other words, given a function application `fn arg`,
    

  • compiler/GHC/Tc/Gen/Head.hs
    ... ... @@ -655,7 +655,7 @@ tcInferOverLit lit@(OverLit { ol_val = val
    655 655
            ; let
    
    656 656
                thing    = NameThing from_name
    
    657 657
                mb_thing = Just thing
    
    658
    -           herald   = ExpectedFunTyArg 1 thing (HsLit noExtField hs_lit)
    
    658
    +           herald   = ExpectedFunTyArg thing (HsLit noExtField hs_lit)
    
    659 659
            ; (wrap2, sarg_ty, res_ty) <- matchActualFunTy herald mb_thing (1, from_ty) from_ty
    
    660 660
     
    
    661 661
            ; co <- unifyType mb_thing (hsLitType hs_lit) (scaledThing sarg_ty)
    

  • compiler/GHC/Tc/Types/Origin.hs
    ... ... @@ -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 }))
    

  • compiler/hie.yaml
    1
    +# This is a IDE configuration file which tells IDEs such as `ghcide` how
    
    2
    +# to set up a GHC API session for this project.
    
    3
    +#
    
    4
    +# To use it in windows systems replace the config with
    
    5
    +# cradle: {bios: {program: "./hadrian/hie-bios.bat"}}
    
    6
    +#
    
    7
    +# The format is documented here - https://github.com/mpickering/hie-bios
    
    8
    +cradle: {bios: {program: "./hadrian/hie-bios",
    
    9
    +	       	with-ghc: "~/.ghcup/bin/ghc" }}