Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

13 changed files:

Changes:

  • compiler/GHC/Core/TyCo/FVs.hs
    ... ... @@ -635,7 +635,9 @@ tyCoFVsOfType (TyConApp _ tys) f bound_vars acc = tyCoFVsOfTypes tys f bound_v
    635 635
                                                         -- See Note [Free vars and synonyms]
    
    636 636
     tyCoFVsOfType (LitTy {})         f bound_vars acc = emptyFV f bound_vars acc
    
    637 637
     tyCoFVsOfType (AppTy fun arg)    f bound_vars acc = (tyCoFVsOfType fun `unionFV` tyCoFVsOfType arg) f bound_vars acc
    
    638
    -tyCoFVsOfType (FunTy _ w arg res)  f bound_vars acc = (tyCoFVsOfType w `unionFV` tyCoFVsOfType arg `unionFV` tyCoFVsOfType res) f bound_vars acc
    
    638
    +tyCoFVsOfType (FunTy _ w arg res)  f bound_vars acc =
    
    639
    +  -- As per #23764, if we have 'a %m -> b', quantification order should be [a,m,b] not [m,a,b].
    
    640
    +  (tyCoFVsOfType arg `unionFV` tyCoFVsOfType w `unionFV` tyCoFVsOfType res) f bound_vars acc
    
    639 641
     tyCoFVsOfType (ForAllTy bndr ty) f bound_vars acc = tyCoFVsBndr bndr (tyCoFVsOfType ty)  f bound_vars acc
    
    640 642
     tyCoFVsOfType (CastTy ty co)     f bound_vars acc = (tyCoFVsOfType ty `unionFV` tyCoFVsOfCo co) f bound_vars acc
    
    641 643
     tyCoFVsOfType (CoercionTy co)    f bound_vars acc = tyCoFVsOfCo co f bound_vars acc
    
    ... ... @@ -958,7 +960,9 @@ invisibleVarsOfType = go
    958 960
                               = go ty'
    
    959 961
         go (TyVarTy v)        = go (tyVarKind v)
    
    960 962
         go (AppTy f a)        = go f `unionFV` go a
    
    961
    -    go (FunTy _ w ty1 ty2) = go w `unionFV` go ty1 `unionFV` go ty2
    
    963
    +    go (FunTy _ w ty1 ty2) =
    
    964
    +      -- As per #23764, order is: arg, mult, res.
    
    965
    +      go ty1 `unionFV` go w `unionFV` go ty2
    
    962 966
         go (TyConApp tc tys)  = tyCoFVsOfTypes invisibles `unionFV`
    
    963 967
                                 invisibleVarsOfTypes visibles
    
    964 968
           where (invisibles, visibles) = partitionInvisibleTypes tc tys
    

  • compiler/GHC/Core/TyCo/Rep.hs
    ... ... @@ -1984,7 +1984,9 @@ foldTyCo (TyCoFolder { tcf_view = view
    1984 1984
         go_ty _   (LitTy {})        = mempty
    
    1985 1985
         go_ty env (CastTy ty co)    = go_ty env ty `mappend` go_co env co
    
    1986 1986
         go_ty env (CoercionTy co)   = go_co env co
    
    1987
    -    go_ty env (FunTy _ w arg res) = go_ty env w `mappend` go_ty env arg `mappend` go_ty env res
    
    1987
    +    go_ty env (FunTy _ w arg res) =
    
    1988
    +      -- As per #23764, ordering is [arg, w, res].
    
    1989
    +      go_ty env arg `mappend` go_ty env w `mappend` go_ty env res
    
    1988 1990
         go_ty env (TyConApp _ tys)  = go_tys env tys
    
    1989 1991
         go_ty env (ForAllTy (Bndr tv vis) inner)
    
    1990 1992
           = let !env' = tycobinder env tv vis  -- Avoid building a thunk here
    

  • compiler/GHC/Tc/Utils/TcMType.hs
    ... ... @@ -1432,7 +1432,7 @@ collect_cand_qtvs orig_ty is_dep cur_lvl bound dvs ty
    1432 1432
         -- Uses accumulating-parameter style
    
    1433 1433
         go dv (AppTy t1 t2)       = foldlM go dv [t1, t2]
    
    1434 1434
         go dv (TyConApp tc tys)   = go_tc_args dv (tyConBinders tc) tys
    
    1435
    -    go dv (FunTy _ w arg res) = foldlM go dv [w, arg, res]
    
    1435
    +    go dv (FunTy _ w arg res) = foldlM go dv [arg, w, res]
    
    1436 1436
         go dv (LitTy {})          = return dv
    
    1437 1437
         go dv (CastTy ty co)      = do { dv1 <- go dv ty
    
    1438 1438
                                        ; collect_cand_qtvs_co orig_ty cur_lvl bound dv1 co }
    

  • compiler/GHC/Tc/Utils/TcType.hs
    ... ... @@ -1009,8 +1009,8 @@ tcTyFamInstsAndVisX = go
    1009 1009
         go _            (LitTy {})         = []
    
    1010 1010
         go is_invis_arg (ForAllTy bndr ty) = go is_invis_arg (binderType bndr)
    
    1011 1011
                                              ++ go is_invis_arg ty
    
    1012
    -    go is_invis_arg (FunTy _ w ty1 ty2)  = go is_invis_arg w
    
    1013
    -                                         ++ go is_invis_arg ty1
    
    1012
    +    go is_invis_arg (FunTy _ w ty1 ty2)  =  go is_invis_arg ty1
    
    1013
    +                                         ++ go is_invis_arg w
    
    1014 1014
                                              ++ go is_invis_arg ty2
    
    1015 1015
         go is_invis_arg ty@(AppTy _ _)     =
    
    1016 1016
           let (ty_head, ty_args) = splitAppTys ty
    

  • utils/haddock/haddock-api/src/Haddock/Convert.hs
    ... ... @@ -29,7 +29,7 @@ module Haddock.Convert
    29 29
     
    
    30 30
     import Control.DeepSeq (force)
    
    31 31
     import Data.Either (lefts, partitionEithers, rights)
    
    32
    -import Data.Maybe (catMaybes, mapMaybe, maybeToList)
    
    32
    +import Data.Maybe (catMaybes, mapMaybe)
    
    33 33
     import GHC.Builtin.Names
    
    34 34
       ( boxedRepDataConKey
    
    35 35
       , eqTyConKey
    
    ... ... @@ -140,7 +140,7 @@ tyThingToLHsDecl prr t = case t of
    140 140
                             hsq_explicit $
    
    141 141
                               fdTyVars fd
    
    142 142
                       , feqn_fixity = fdFixity fd
    
    143
    -                  , feqn_rhs = synifyType WithinType [] rhs
    
    143
    +                  , feqn_rhs = synifyType WithinType emptyVarSet rhs
    
    144 144
                       }
    
    145 145
     
    
    146 146
                 extractAtItem
    
    ... ... @@ -179,7 +179,7 @@ tyThingToLHsDecl prr t = case t of
    179 179
                         noLocA (MinimalSig (noAnn, NoSourceText) . noLocA $ classMinimalDef cl)
    
    180 180
                           : [ noLocA tcdSig
    
    181 181
                             | clsOp <- classOpItems cl
    
    182
    -                        , tcdSig <- synifyTcIdSig vs clsOp
    
    182
    +                        , tcdSig <- synifyTcIdSig (mkVarSet vs) clsOp
    
    183 183
                             ]
    
    184 184
                     , tcdMeths = [] -- ignore default method definitions, they don't affect signature
    
    185 185
                     -- class associated-types are a subset of TyCon:
    
    ... ... @@ -213,9 +213,9 @@ synifyAxBranch :: TyCon -> CoAxBranch -> TyFamInstEqn GhcRn
    213 213
     synifyAxBranch tc (CoAxBranch{cab_tvs = tkvs, cab_lhs = args, cab_rhs = rhs}) =
    
    214 214
       let name = synifyNameN tc
    
    215 215
           args_types_only = filterOutInvisibleTypes tc args
    
    216
    -      typats = map (synifyType WithinType []) args_types_only
    
    216
    +      typats = map (synifyType WithinType emptyVarSet) args_types_only
    
    217 217
           annot_typats = zipWith3 annotHsType args_poly args_types_only typats
    
    218
    -      hs_rhs = synifyType WithinType [] rhs
    
    218
    +      hs_rhs = synifyType WithinType emptyVarSet rhs
    
    219 219
           outer_bndrs = HsOuterImplicit{hso_ximplicit = map tyVarName tkvs}
    
    220 220
        in -- TODO: this must change eventually
    
    221 221
           FamEqn
    
    ... ... @@ -344,7 +344,7 @@ synifyTyCon _prr coax tc
    344 344
               , tcdLName = synifyNameN tc
    
    345 345
               , tcdTyVars = synifyTyVars (tyConVisibleTyVars tc)
    
    346 346
               , tcdFixity = synifyFixity tc
    
    347
    -          , tcdRhs = synifyType WithinType [] ty
    
    347
    +          , tcdRhs = synifyType WithinType emptyVarSet ty
    
    348 348
               }
    
    349 349
       -- (closed) newtype and data
    
    350 350
       | otherwise = do
    
    ... ... @@ -578,8 +578,8 @@ synifyDataCon use_gadt_syntax dc =
    578 578
         linear_tys =
    
    579 579
           zipWith
    
    580 580
             ( \(Scaled mult ty) (HsSrcBang st unp str) ->
    
    581
    -            let tySyn = synifyType WithinType [] ty
    
    582
    -                multSyn = synifyMultRec [] mult
    
    581
    +            let tySyn = synifyType WithinType emptyVarSet ty
    
    582
    +                multSyn = synifyMultRec emptyVarSet mult
    
    583 583
                 in CDF (noAnn, st) unp str multSyn tySyn Nothing
    
    584 584
             )
    
    585 585
             arg_tys
    
    ... ... @@ -620,7 +620,7 @@ synifyDataCon use_gadt_syntax dc =
    620 620
                   , con_inner_bndrs = inner_bndrs
    
    621 621
                   , con_mb_cxt = ctx
    
    622 622
                   , con_g_args = hat
    
    623
    -              , con_res_ty = synifyType WithinType [] res_ty
    
    623
    +              , con_res_ty = synifyType WithinType emptyVarSet res_ty
    
    624 624
                   , con_doc = Nothing
    
    625 625
                   }
    
    626 626
           else do
    
    ... ... @@ -657,11 +657,11 @@ synifyIdSig
    657 657
       -> SynifyTypeState
    
    658 658
       -- ^ what to do with a 'forall'
    
    659 659
       -> [TyVar]
    
    660
    -  -- ^ free variables in the type to convert
    
    660
    +  -- ^ type variables bound from an outer scope
    
    661 661
       -> Id
    
    662 662
       -- ^ the 'Id' from which to get the type signature
    
    663 663
       -> Sig GhcRn
    
    664
    -synifyIdSig prr s vs i = TypeSig noAnn [n] (synifySigWcType s vs t)
    
    664
    +synifyIdSig prr s boundTvs i = TypeSig noAnn [n] (synifySigWcType s boundTvs t)
    
    665 665
       where
    
    666 666
         !n = force $ synifyNameN i
    
    667 667
         t = defaultType prr (varType i)
    
    ... ... @@ -669,18 +669,18 @@ synifyIdSig prr s vs i = TypeSig noAnn [n] (synifySigWcType s vs t)
    669 669
     -- | Turn a 'ClassOpItem' into a list of signatures. The list returned is going
    
    670 670
     -- to contain the synified 'ClassOpSig' as well (when appropriate) a default
    
    671 671
     -- 'ClassOpSig'.
    
    672
    -synifyTcIdSig :: [TyVar] -> ClassOpItem -> [Sig GhcRn]
    
    673
    -synifyTcIdSig vs (i, dm) =
    
    672
    +synifyTcIdSig :: TyVarSet -> ClassOpItem -> [Sig GhcRn]
    
    673
    +synifyTcIdSig boundTvs (i, dm) =
    
    674 674
       [ClassOpSig noAnn False [synifyNameN i] (mainSig (varType i))]
    
    675 675
         ++ [ ClassOpSig noAnn True [noLocA dn] (defSig dt)
    
    676 676
            | Just (dn, GenericDM dt) <- [dm]
    
    677 677
            ]
    
    678 678
       where
    
    679
    -    mainSig t = synifySigType DeleteTopLevelQuantification vs t
    
    680
    -    defSig t = synifySigType ImplicitizeForAll vs t
    
    679
    +    mainSig t = synifySigType DeleteTopLevelQuantification boundTvs t
    
    680
    +    defSig t = synifySigType ImplicitizeForAll boundTvs t
    
    681 681
     
    
    682 682
     synifyCtx :: [PredType] -> LHsContext GhcRn
    
    683
    -synifyCtx ts = noLocA (map (synifyType WithinType []) ts)
    
    683
    +synifyCtx ts = noLocA (map (synifyType WithinType emptyVarSet) ts)
    
    684 684
     
    
    685 685
     synifyTyVars :: [TyVar] -> LHsQTyVars GhcRn
    
    686 686
     synifyTyVars ktvs =
    
    ... ... @@ -699,7 +699,7 @@ synifyTyVarBndr' :: VarSet -> VarBndr TyVar flag -> LHsTyVarBndr flag GhcRn
    699 699
     synifyTyVarBndr' no_kinds (Bndr tv spec) = synify_ty_var no_kinds spec tv
    
    700 700
     
    
    701 701
     -- | Like 'synifyTyVarBndr', but accepts a set of variables for which to omit kind
    
    702
    --- signatures (even if they don't have the lifted type kind).
    
    702
    +-- signatures (even if they don't have kind 'Type').
    
    703 703
     synify_ty_var :: VarSet -> flag -> TyVar -> LHsTyVarBndr flag GhcRn
    
    704 704
     synify_ty_var no_kinds flag tv =
    
    705 705
       noLocA (HsTvb noAnn flag bndr_var bndr_kind)
    
    ... ... @@ -726,7 +726,7 @@ annotHsType _ _ hs_ty@(L _ (HsKindSig{})) = hs_ty
    726 726
     annotHsType True ty hs_ty
    
    727 727
       | not $ isEmptyVarSet $ filterVarSet isTyVar $ tyCoVarsOfType ty =
    
    728 728
           let ki = typeKind ty
    
    729
    -          hs_ki = synifyType WithinType [] ki
    
    729
    +          hs_ki = synifyType WithinType emptyVarSet ki
    
    730 730
            in noLocA (HsKindSig noAnn hs_ty hs_ki)
    
    731 731
     annotHsType _ _ hs_ty = hs_ty
    
    732 732
     
    
    ... ... @@ -768,14 +768,15 @@ data SynifyTypeState
    768 768
         --   the defining class gets to quantify all its functions for free!
    
    769 769
         DeleteTopLevelQuantification
    
    770 770
     
    
    771
    -synifySigType :: SynifyTypeState -> [TyVar] -> Type -> LHsSigType GhcRn
    
    771
    +synifySigType :: SynifyTypeState -> TyVarSet -> Type -> LHsSigType GhcRn
    
    772 772
     -- The use of mkEmptySigType (which uses empty binders in OuterImplicit)
    
    773 773
     -- is a bit suspicious; what if the type has free variables?
    
    774
    -synifySigType s vs ty = mkEmptySigType (synifyType s vs ty)
    
    774
    +synifySigType s boundTvs ty = mkEmptySigType (synifyType s boundTvs ty)
    
    775 775
     
    
    776 776
     synifySigWcType :: SynifyTypeState -> [TyVar] -> Type -> LHsSigWcType GhcRn
    
    777 777
     -- Ditto (see synifySigType)
    
    778
    -synifySigWcType s vs ty = mkEmptyWildCardBndrs (mkEmptySigType (rename (map getName vs) $ synifyType s vs ty))
    
    778
    +synifySigWcType s vs ty =
    
    779
    +  mkEmptyWildCardBndrs (mkEmptySigType (rename (map getName vs) $ synifyType s (mkVarSet vs) ty))
    
    779 780
     
    
    780 781
     synifyPatSynSigType :: PatSyn -> LHsSigType GhcRn
    
    781 782
     -- Ditto (see synifySigType)
    
    ... ... @@ -791,13 +792,13 @@ defaultType HideRuntimeRep = defaultRuntimeRepVars
    791 792
     synifyType
    
    792 793
       :: SynifyTypeState
    
    793 794
       -- ^ what to do with a 'forall'
    
    794
    -  -> [TyVar]
    
    795
    -  -- ^ free variables in the type to convert
    
    795
    +  -> TyVarSet
    
    796
    +  -- ^ bound type variables
    
    796 797
       -> Type
    
    797 798
       -- ^ the type to convert
    
    798 799
       -> LHsType GhcRn
    
    799 800
     synifyType _ _ (TyVarTy tv) = noLocA $ HsTyVar noAnn NotPromoted $ noLocA (noUserRdr $ getName tv)
    
    800
    -synifyType _ vs (TyConApp tc tys) =
    
    801
    +synifyType _ boundTvs (TyConApp tc tys) =
    
    801 802
       maybe_sig res_ty
    
    802 803
       where
    
    803 804
         res_ty :: LHsType GhcRn
    
    ... ... @@ -819,24 +820,24 @@ synifyType _ vs (TyConApp tc tys) =
    819 820
                       ConstraintTuple -> HsBoxedOrConstraintTuple
    
    820 821
                       UnboxedTuple -> HsUnboxedTuple
    
    821 822
                   )
    
    822
    -              (map (synifyType WithinType vs) vis_tys)
    
    823
    +              (map (synifyType WithinType boundTvs) vis_tys)
    
    823 824
           | isUnboxedSumTyCon tc =
    
    824
    -          noLocA $ HsSumTy noAnn (map (synifyType WithinType vs) vis_tys)
    
    825
    +          noLocA $ HsSumTy noAnn (map (synifyType WithinType boundTvs) vis_tys)
    
    825 826
           | Just dc <- isPromotedDataCon_maybe tc
    
    826 827
           , isTupleDataCon dc
    
    827 828
           , dataConSourceArity dc == length vis_tys =
    
    828
    -          noLocA $ HsExplicitTupleTy noExtField IsPromoted (map (synifyType WithinType vs) vis_tys)
    
    829
    +          noLocA $ HsExplicitTupleTy noExtField IsPromoted (map (synifyType WithinType boundTvs) vis_tys)
    
    829 830
           -- ditto for lists
    
    830 831
           | getName tc == listTyConName
    
    831 832
           , [ty] <- vis_tys =
    
    832
    -          noLocA $ HsListTy noAnn (synifyType WithinType vs ty)
    
    833
    +          noLocA $ HsListTy noAnn (synifyType WithinType boundTvs ty)
    
    833 834
           | tc == promotedNilDataCon
    
    834 835
           , [] <- vis_tys =
    
    835 836
               noLocA $ HsExplicitListTy noExtField IsPromoted []
    
    836 837
           | tc == promotedConsDataCon
    
    837 838
           , [ty1, ty2] <- vis_tys =
    
    838
    -          let hTy = synifyType WithinType vs ty1
    
    839
    -           in case synifyType WithinType vs ty2 of
    
    839
    +          let hTy = synifyType WithinType boundTvs ty1
    
    840
    +           in case synifyType WithinType boundTvs ty2 of
    
    840 841
                     tTy
    
    841 842
                       | L _ (HsExplicitListTy _ IsPromoted tTy') <- stripKindSig tTy ->
    
    842 843
                           noLocA $ HsExplicitListTy noExtField IsPromoted (hTy : tTy')
    
    ... ... @@ -846,7 +847,7 @@ synifyType _ vs (TyConApp tc tys) =
    846 847
           | tc `hasKey` ipClassKey
    
    847 848
           , [name, ty] <- tys
    
    848 849
           , Just x <- isStrLitTy name =
    
    849
    -          noLocA $ HsIParamTy noAnn (noLocA $ HsIPName x) (synifyType WithinType vs ty)
    
    850
    +          noLocA $ HsIParamTy noAnn (noLocA $ HsIPName x) (synifyType WithinType boundTvs ty)
    
    850 851
           -- and equalities
    
    851 852
           | tc `hasKey` eqTyConKey
    
    852 853
           , [ty1, ty2] <- tys =
    
    ... ... @@ -854,9 +855,9 @@ synifyType _ vs (TyConApp tc tys) =
    854 855
                 HsOpTy
    
    855 856
                   noExtField
    
    856 857
                   NotPromoted
    
    857
    -              (synifyType WithinType vs ty1)
    
    858
    +              (synifyType WithinType boundTvs ty1)
    
    858 859
                   (noLocA $ noUserRdr eqTyConName)
    
    859
    -              (synifyType WithinType vs ty2)
    
    860
    +              (synifyType WithinType boundTvs ty2)
    
    860 861
           -- and infix type operators
    
    861 862
           | isSymOcc (nameOccName (getName tc))
    
    862 863
           , ty1 : ty2 : tys_rest <- vis_tys =
    
    ... ... @@ -864,9 +865,9 @@ synifyType _ vs (TyConApp tc tys) =
    864 865
                 ( HsOpTy
    
    865 866
                     noExtField
    
    866 867
                     prom
    
    867
    -                (synifyType WithinType vs ty1)
    
    868
    +                (synifyType WithinType boundTvs ty1)
    
    868 869
                     (noLocA $ noUserRdr $ getName tc)
    
    869
    -                (synifyType WithinType vs ty2)
    
    870
    +                (synifyType WithinType boundTvs ty2)
    
    870 871
                 )
    
    871 872
                 tys_rest
    
    872 873
           -- Most TyCons:
    
    ... ... @@ -880,7 +881,7 @@ synifyType _ vs (TyConApp tc tys) =
    880 881
               foldl
    
    881 882
                 (\t1 t2 -> noLocA $ HsAppTy noExtField t1 t2)
    
    882 883
                 (noLocA ty_app)
    
    883
    -            ( map (synifyType WithinType vs) $
    
    884
    +            ( map (synifyType WithinType boundTvs) $
    
    884 885
                     filterOut isCoercionTy ty_args
    
    885 886
                 )
    
    886 887
     
    
    ... ... @@ -891,56 +892,57 @@ synifyType _ vs (TyConApp tc tys) =
    891 892
         maybe_sig ty'
    
    892 893
           | tyConAppNeedsKindSig False tc tys_len =
    
    893 894
               let full_kind = typeKind (mkTyConApp tc tys)
    
    894
    -              full_kind' = synifyType WithinType vs full_kind
    
    895
    +              full_kind' = synifyType WithinType boundTvs full_kind
    
    895 896
                in noLocA $ HsKindSig noAnn ty' full_kind'
    
    896 897
           | otherwise = ty'
    
    897
    -synifyType _ vs ty@(AppTy{}) =
    
    898
    +synifyType _ boundTvs ty@(AppTy{}) =
    
    898 899
       let
    
    899 900
         (ty_head, ty_args) = splitAppTys ty
    
    900
    -    ty_head' = synifyType WithinType vs ty_head
    
    901
    +    ty_head' = synifyType WithinType boundTvs ty_head
    
    901 902
         ty_args' =
    
    902
    -      map (synifyType WithinType vs) $
    
    903
    +      map (synifyType WithinType boundTvs) $
    
    903 904
             filterOut isCoercionTy $
    
    904 905
               filterByList
    
    905 906
                 (map isVisibleForAllTyFlag $ appTyForAllTyFlags ty_head ty_args)
    
    906 907
                 ty_args
    
    907 908
        in
    
    908 909
         foldl (\t1 t2 -> noLocA $ HsAppTy noExtField t1 t2) ty_head' ty_args'
    
    909
    -synifyType s vs funty@(FunTy af w t1 t2)
    
    910
    -  | isInvisibleFunArg af = synifySigmaType s vs funty
    
    910
    +synifyType s boundTvs funty@(FunTy af w t1 t2)
    
    911
    +  | isInvisibleFunArg af = synifySigmaType s boundTvs funty
    
    911 912
       | otherwise = noLocA $ HsFunTy noExtField w' s1 s2
    
    912 913
       where
    
    913
    -    s1 = synifyType WithinType vs t1
    
    914
    -    s2 = synifyType WithinType vs t2
    
    915
    -    w' = synifyMultArrow vs w
    
    916
    -synifyType s vs forallty@(ForAllTy (Bndr _ argf) _ty) =
    
    914
    +    s1 = synifyType WithinType boundTvs t1
    
    915
    +    s2 = synifyType WithinType boundTvs t2
    
    916
    +    w' = synifyMultArrow boundTvs w
    
    917
    +synifyType s boundTvs forallty@(ForAllTy (Bndr _ argf) _ty) =
    
    917 918
       case argf of
    
    918
    -    Required -> synifyVisForAllType vs forallty
    
    919
    -    Invisible _ -> synifySigmaType s vs forallty
    
    919
    +    Required -> synifyVisForAllType boundTvs forallty
    
    920
    +    Invisible _ -> synifySigmaType s boundTvs forallty
    
    920 921
     synifyType _ _ (LitTy t) = noLocA $ HsTyLit noExtField $ synifyTyLit t
    
    921
    -synifyType s vs (CastTy t _) = synifyType s vs t
    
    922
    +synifyType s boundTvs (CastTy t _) = synifyType s boundTvs t
    
    922 923
     synifyType _ _ (CoercionTy{}) = error "synifyType:Coercion"
    
    923 924
     
    
    924 925
     -- | Process a 'Type' which starts with a visible @forall@ into an 'HsType'
    
    925 926
     synifyVisForAllType
    
    926
    -  :: [TyVar]
    
    927
    -  -- ^ free variables in the type to convert
    
    927
    +  :: TyVarSet
    
    928
    +  -- ^ bound type variables
    
    928 929
       -> Type
    
    929 930
       -- ^ the forall type to convert
    
    930 931
       -> LHsType GhcRn
    
    931
    -synifyVisForAllType vs ty =
    
    932
    +synifyVisForAllType boundTvs ty =
    
    932 933
       let (tvs, rho) = tcSplitForAllTysReqPreserveSynonyms ty
    
    933 934
     
    
    934
    -      sTvs = map synifyTyVarBndr tvs
    
    935
    +      sTvs = map (synifyTyVarBndr' noKindSigTvs) tvs
    
    936
    +      noKindSigTvs = noKindSigTyVars ty
    
    935 937
     
    
    936 938
           -- Figure out what the type variable order would be inferred in the
    
    937 939
           -- absence of an explicit forall
    
    938
    -      tvs' = orderedFVs (mkVarSet vs) [rho]
    
    940
    +      tvs' = orderedFVs boundTvs [rho]
    
    939 941
        in noLocA $
    
    940 942
             HsForAllTy
    
    941 943
               { hst_tele = mkHsForAllVisTele noAnn sTvs
    
    942 944
               , hst_xforall = noExtField
    
    943
    -          , hst_body = synifyType WithinType (tvs' ++ vs) rho
    
    945
    +          , hst_body = synifyType WithinType (extendVarSetList boundTvs tvs') rho
    
    944 946
               }
    
    945 947
     
    
    946 948
     -- | Process a 'Type' which starts with an invisible @forall@ or a constraint
    
    ... ... @@ -948,18 +950,18 @@ synifyVisForAllType vs ty =
    948 950
     synifySigmaType
    
    949 951
       :: SynifyTypeState
    
    950 952
       -- ^ what to do with the 'forall'
    
    951
    -  -> [TyVar]
    
    952
    -  -- ^ free variables in the type to convert
    
    953
    +  -> TyVarSet
    
    954
    +  -- ^ bound type variables
    
    953 955
       -> Type
    
    954 956
       -- ^ the forall type to convert
    
    955 957
       -> LHsType GhcRn
    
    956
    -synifySigmaType s vs ty =
    
    958
    +synifySigmaType s boundTvs ty =
    
    957 959
       let (tvs, ctx, tau) = tcSplitSigmaTyPreserveSynonyms ty
    
    958 960
           sPhi =
    
    959 961
             HsQualTy
    
    960 962
               { hst_ctxt = synifyCtx ctx
    
    961 963
               , hst_xqual = noExtField
    
    962
    -          , hst_body = synifyType WithinType (tvs' ++ vs) tau
    
    964
    +          , hst_body = synifyType WithinType (extendVarSetList boundTvs tvs' ) tau
    
    963 965
               }
    
    964 966
     
    
    965 967
           sTy =
    
    ... ... @@ -969,49 +971,56 @@ synifySigmaType s vs ty =
    969 971
               , hst_body = noLocA sPhi
    
    970 972
               }
    
    971 973
     
    
    972
    -      sTvs = map synifyTyVarBndr tvs
    
    974
    +      sTvs = map (synifyTyVarBndr' noKindSigTvs) tvs
    
    975
    +
    
    976
    +      noKindSigTvs = noKindSigTyVars ty
    
    973 977
     
    
    974 978
           -- Figure out what the type variable order would be inferred in the
    
    975 979
           -- absence of an explicit forall
    
    976
    -      tvs' = orderedFVs (mkVarSet vs) (ctx ++ [tau])
    
    980
    +      tvs' = orderedFVs boundTvs (ctx ++ [tau])
    
    977 981
        in case s of
    
    978
    -        DeleteTopLevelQuantification -> synifyType ImplicitizeForAll (tvs' ++ vs) tau
    
    982
    +        DeleteTopLevelQuantification -> synifyType ImplicitizeForAll (extendVarSetList boundTvs tvs') tau
    
    979 983
             -- Put a forall in if there are any type variables
    
    980 984
             WithinType
    
    981 985
               | not (null tvs) -> noLocA sTy
    
    982 986
               | otherwise -> noLocA sPhi
    
    983
    -        ImplicitizeForAll -> implicitForAll [] vs tvs ctx (synifyType WithinType) tau
    
    987
    +        ImplicitizeForAll -> implicitForAll boundTvs tvs ctx (synifyType WithinType) tau
    
    984 988
     
    
    985
    --- | Put a forall in if there are any type variables which require
    
    986
    --- explicit kind annotations or if the inferred type variable order
    
    987
    --- would be different.
    
    989
    +-- | Use an explicit forall if there are any type variables which require
    
    990
    +-- explicit kind annotations or if the inferred type variable quantification
    
    991
    +-- order would be different.
    
    988 992
     implicitForAll
    
    989
    -  :: [TyCon]
    
    990
    -  -- ^ type constructors that determine their args kinds
    
    991
    -  -> [TyVar]
    
    992
    -  -- ^ free variables in the type to convert
    
    993
    +  :: TyVarSet
    
    994
    +  -- ^ bound type variables (e.g. bound from an outer scope)
    
    993 995
       -> [InvisTVBinder]
    
    994 996
       -- ^ type variable binders in the forall
    
    995 997
       -> ThetaType
    
    996 998
       -- ^ constraints right after the forall
    
    997
    -  -> ([TyVar] -> Type -> LHsType GhcRn)
    
    999
    +  -> (TyVarSet -> Type -> LHsType GhcRn)
    
    998 1000
       -- ^ how to convert the inner type
    
    999 1001
       -> Type
    
    1000 1002
       -- ^ inner type
    
    1001 1003
       -> LHsType GhcRn
    
    1002
    -implicitForAll tycons vs tvs ctx synInner tau
    
    1003
    -  | any (isHsKindedTyVar . unLoc) sTvs = noLocA sTy
    
    1004
    -  | tvs' /= (binderVars tvs) = noLocA sTy
    
    1005
    -  | otherwise = noLocA sPhi
    
    1004
    +implicitForAll boundTvs tvbs ctx synInner tau
    
    1005
    +  | any (isHsKindedTyVar . unLoc) sTvs
    
    1006
    +  -- Explicit forall: some type variable needs an explicit kind annotation.
    
    1007
    +  = noLocA sTy
    
    1008
    +  | tvs /= inferredFreeTvs
    
    1009
    +  -- Explicit forall: the inferred quantification order would be different.
    
    1010
    +  = noLocA sTy
    
    1011
    +  | otherwise
    
    1012
    +  -- Implicit forall.
    
    1013
    +  = noLocA sPhi
    
    1006 1014
       where
    
    1007
    -    sRho = synInner (tvs' ++ vs) tau
    
    1015
    +    tvs = binderVars tvbs
    
    1016
    +    sRho = synInner (extendVarSetList boundTvs inferredFreeTvs) tau
    
    1008 1017
         sPhi
    
    1009 1018
           | null ctx = unLoc sRho
    
    1010 1019
           | otherwise =
    
    1011 1020
               HsQualTy
    
    1012 1021
                 { hst_ctxt = synifyCtx ctx
    
    1013 1022
                 , hst_xqual = noExtField
    
    1014
    -            , hst_body = synInner (tvs' ++ vs) tau
    
    1023
    +            , hst_body = sRho
    
    1015 1024
                 }
    
    1016 1025
         sTy =
    
    1017 1026
           HsForAllTy
    
    ... ... @@ -1020,84 +1029,129 @@ implicitForAll tycons vs tvs ctx synInner tau
    1020 1029
             , hst_body = noLocA sPhi
    
    1021 1030
             }
    
    1022 1031
     
    
    1023
    -    no_kinds_needed = noKindTyVars tycons tau
    
    1024
    -    sTvs = map (synifyTyVarBndr' no_kinds_needed) tvs
    
    1032
    +    no_kinds_needed = noKindSigTyVars tau
    
    1033
    +    sTvs = map (synifyTyVarBndr' no_kinds_needed) tvbs
    
    1025 1034
     
    
    1026 1035
         -- Figure out what the type variable order would be inferred in the
    
    1027 1036
         -- absence of an explicit forall
    
    1028
    -    tvs' = orderedFVs (mkVarSet vs) (ctx ++ [tau])
    
    1037
    +    inferredFreeTvs = orderedFVs boundTvs (ctx ++ [tau])
    
    1029 1038
     
    
    1030
    --- | Find the set of type variables whose kind signatures can be properly
    
    1031
    --- inferred just from their uses in the type signature. This means the type
    
    1032
    --- variable to has at least one fully applied use @f x1 x2 ... xn@ where:
    
    1039
    +-- | Returns a subset of the free type variables of the given type whose kinds
    
    1040
    +-- can definitely be inferred from their occurrences in the type.
    
    1033 1041
     --
    
    1034
    ---   * @f@ has a function kind where the arguments have the same kinds
    
    1035
    ---     as @x1 x2 ... xn@.
    
    1042
    +-- This function is only a simple heuristic, which is used in order to avoid
    
    1043
    +-- needlessly cluttering Haddocks with explicit foralls that are not needed.
    
    1044
    +-- This function may return some type variables for which we aren't sure
    
    1045
    +-- (which will cause us to display the type with an explicit forall, just in
    
    1046
    +-- case).
    
    1036 1047
     --
    
    1037
    ---   * @f@ has a function kind whose final return has lifted type kind
    
    1038
    -noKindTyVars
    
    1039
    -  :: [TyCon]
    
    1040
    -  -- ^ type constructors that determine their args kinds
    
    1041
    -  -> Type
    
    1048
    +-- In the future, we hope to address the issue of whether to print a type with
    
    1049
    +-- an explicit forall by storing whether the user wrote the type with an
    
    1050
    +-- explicit forall in the first place (see GHC ticket #26271).
    
    1051
    +noKindSigTyVars
    
    1052
    +  :: Type
    
    1042 1053
       -- ^ type to inspect
    
    1043 1054
       -> VarSet
    
    1044
    -  -- ^ set of variables whose kinds can be inferred from uses in the type
    
    1045
    -noKindTyVars _ (TyVarTy var)
    
    1046
    -  | isLiftedTypeKind (tyVarKind var) = unitVarSet var
    
    1047
    -noKindTyVars ts ty
    
    1048
    -  | (f, xs) <- splitAppTys ty
    
    1049
    -  , not (null xs) =
    
    1050
    -      let args = map (noKindTyVars ts) xs
    
    1051
    -          func = case f of
    
    1052
    -            TyVarTy var
    
    1053
    -              | (xsKinds, outKind) <- splitFunTys (tyVarKind var)
    
    1054
    -              , map scaledThing xsKinds `eqTypes` map typeKind xs
    
    1055
    -              , isLiftedTypeKind outKind ->
    
    1056
    -                  unitVarSet var
    
    1057
    -            TyConApp t ks
    
    1058
    -              | t `elem` ts
    
    1059
    -              , all noFreeVarsOfType ks ->
    
    1060
    -                  mkVarSet [v | TyVarTy v <- xs]
    
    1061
    -            _ -> noKindTyVars ts f
    
    1062
    -       in unionVarSets (func : args)
    
    1063
    -noKindTyVars ts (ForAllTy _ t) = noKindTyVars ts t
    
    1064
    -noKindTyVars ts (FunTy _ w t1 t2) =
    
    1065
    -  noKindTyVars ts w
    
    1066
    -    `unionVarSet` noKindTyVars ts t1
    
    1067
    -    `unionVarSet` noKindTyVars ts t2
    
    1068
    -noKindTyVars ts (CastTy t _) = noKindTyVars ts t
    
    1069
    -noKindTyVars _ _ = emptyVarSet
    
    1070
    -
    
    1071
    -synifyMultArrow :: [TyVar] -> Mult -> HsMultAnn GhcRn
    
    1072
    -synifyMultArrow vs t = case t of
    
    1055
    +  -- ^ set of variables whose kinds can definitely be inferred from occurrences in the type
    
    1056
    +noKindSigTyVars ty
    
    1057
    +  | Just ty' <- coreView ty
    
    1058
    +  = noKindSigTyVars ty'
    
    1059
    +  -- In a TyConApp 'T ty_1 ... ty_n', if 'ty_i = tv' is a type variable and the
    
    1060
    +  -- i-th argument of the kind of 'T' is monomorphic, then the kind of 'tv'
    
    1061
    +  -- is fully determined by its occurrence in the TyConApp.
    
    1062
    +  | Just (tc, args) <- splitTyConApp_maybe ty
    
    1063
    +  , let (tcArgBndrs, _tcResKi) = splitPiTys (tyConKind tc)
    
    1064
    +        tcArgKis = map (\case { Named (Bndr b _) -> tyVarKind b; Anon (Scaled _ t) _ -> t}) tcArgBndrs
    
    1065
    +  = mono_tvs tcArgKis args `unionVarSet` (mapUnionVarSet noKindSigTyVars args)
    
    1066
    +  -- If we have 'f ty_1 ... ty_n' where 'f :: ki_1 -> ... -> ki_n -> Type'
    
    1067
    +  -- then we can infer the kind of 'f' from the kinds of its arguments.
    
    1068
    +  --
    
    1069
    +  -- This special case handles common examples involving functors, monads...
    
    1070
    +  -- with type signatures such as '(a -> b) -> (f a -> f b)'.
    
    1071
    +  | (TyVarTy fun, args) <- splitAppTys ty
    
    1072
    +  , not (null args)
    
    1073
    +  , (funArgKinds, funResKind) <- splitFunTys (tyVarKind fun)
    
    1074
    +  , map scaledThing funArgKinds `eqTypes` map typeKind args
    
    1075
    +  , isLiftedTypeKind funResKind
    
    1076
    +  = ( `extendVarSet` fun ) $ mapUnionVarSet noKindSigTyVars args
    
    1077
    +  where
    
    1078
    +    mono_tvs :: [Type] -> [Type] -> VarSet
    
    1079
    +    mono_tvs (tcArgKi:tcArgKis) (arg:args)
    
    1080
    +      | TyVarTy arg_tv <- arg
    
    1081
    +      , noFreeVarsOfType tcArgKi
    
    1082
    +      = ( `extendVarSet` arg_tv ) $ mono_tvs tcArgKis args
    
    1083
    +      | otherwise
    
    1084
    +      = mono_tvs tcArgKis args
    
    1085
    +    mono_tvs _ _ = emptyVarSet
    
    1086
    +noKindSigTyVars (ForAllTy _ t) = noKindSigTyVars t
    
    1087
    +noKindSigTyVars (CastTy t _) = noKindSigTyVars t
    
    1088
    +noKindSigTyVars _ = emptyVarSet
    
    1089
    +
    
    1090
    +synifyMultArrow :: TyVarSet -> Mult -> HsMultAnn GhcRn
    
    1091
    +synifyMultArrow boundTvs t = case t of
    
    1073 1092
       OneTy -> HsLinearAnn noExtField
    
    1074 1093
       ManyTy -> HsUnannotated noExtField
    
    1075
    -  ty -> HsExplicitMult noExtField (synifyType WithinType vs ty)
    
    1094
    +  ty -> HsExplicitMult noExtField (synifyType WithinType boundTvs ty)
    
    1076 1095
     
    
    1077
    -synifyMultRec :: [TyVar] -> Mult -> HsMultAnn GhcRn
    
    1078
    -synifyMultRec vs t = case t of
    
    1096
    +synifyMultRec :: TyVarSet -> Mult -> HsMultAnn GhcRn
    
    1097
    +synifyMultRec boundTvs t = case t of
    
    1079 1098
       OneTy -> HsUnannotated noExtField
    
    1080
    -  ty -> HsExplicitMult noExtField (synifyType WithinType vs ty)
    
    1099
    +  ty -> HsExplicitMult noExtField (synifyType WithinType boundTvs ty)
    
    1081 1100
     
    
    1082 1101
     synifyPatSynType :: PatSyn -> LHsType GhcRn
    
    1083 1102
     synifyPatSynType ps =
    
    1084
    -  let (univ_tvs, req_theta, ex_tvs, prov_theta, arg_tys, res_ty) = patSynSigBndr ps
    
    1085
    -      ts = maybeToList (tyConAppTyCon_maybe res_ty)
    
    1103
    +  let (univ_tvbs, req_theta, ex_tvbs, prov_theta, arg_tys, res_ty) = patSynSigBndr ps
    
    1104
    +
    
    1105
    +{- Recall that pattern synonyms have both "required" and "provided" constraints,
    
    1106
    +e.g.
    
    1107
    +
    
    1108
    +  pattern P :: forall a b c. req => forall e f g => prov => arg_ty1 -> ... -> res_ty
    
    1109
    +
    
    1110
    +Here:
    
    1111
    +
    
    1112
    +  a, b, c are universal type variables
    
    1113
    +  req are required constraints
    
    1086 1114
     
    
    1087
    -      -- HACK: a HsQualTy with theta = [unitTy] will be printed as "() =>",
    
    1088
    -      -- i.e., an explicit empty context, which is what we need. This is not
    
    1089
    -      -- possible by taking theta = [], as that will print no context at all
    
    1115
    +  e, f, g are existential type variables
    
    1116
    +  prov are provided constraints
    
    1117
    +
    
    1118
    +The first pair comes from the outside, while the second pair is obtained upon
    
    1119
    +a successful match on the pattern.
    
    1120
    +
    
    1121
    +Remarks:
    
    1122
    +
    
    1123
    +  1. Both foralls are optional.
    
    1124
    +
    
    1125
    +  2. If there is only one =>, we interpret the constraints as required.
    
    1126
    +     Thus, if we want an empty set of required constraints and a non-empty set
    
    1127
    +     of provided constraints, the type signature must be written like
    
    1128
    +
    
    1129
    +       () => prov => res_ty
    
    1130
    +-}
    
    1131
    +
    
    1132
    +
    
    1133
    +      -- Add an explicit "() => ..." when req_theta is empty but there are
    
    1134
    +      -- existential variables or provided constraints.
    
    1090 1135
           req_theta'
    
    1091 1136
             | null req_theta
    
    1092
    -        , not (null prov_theta && null ex_tvs) =
    
    1137
    +        , not (null prov_theta && null ex_tvbs) =
    
    1093 1138
                 [unitTy]
    
    1094 1139
             | otherwise = req_theta
    
    1140
    +      univ_tvs = mkVarSet $ binderVars univ_tvbs
    
    1141
    +      ex_tvs = mkVarSet $ binderVars ex_tvbs
    
    1142
    +
    
    1143
    +
    
    1095 1144
        in implicitForAll
    
    1096
    -        ts
    
    1097
    -        []
    
    1098
    -        (univ_tvs ++ ex_tvs)
    
    1145
    +        ex_tvs    -- consider the ex_tvs non-free, so that we don't quantify over them here
    
    1146
    +        univ_tvbs -- quantify only over the universals
    
    1099 1147
             req_theta'
    
    1100
    -        (\vs -> implicitForAll ts vs [] prov_theta (synifyType WithinType))
    
    1148
    +        ( \_ ->
    
    1149
    +          implicitForAll
    
    1150
    +            univ_tvs -- the univ_tvs are already bound
    
    1151
    +            ex_tvbs  -- quantify only over the existentials
    
    1152
    +            prov_theta
    
    1153
    +            (synifyType WithinType)
    
    1154
    +        )
    
    1101 1155
             (mkScaledFunTys arg_tys res_ty)
    
    1102 1156
     
    
    1103 1157
     synifyTyLit :: TyLit -> HsTyLit GhcRn
    
    ... ... @@ -1106,7 +1160,7 @@ synifyTyLit (StrTyLit s) = HsStrTy NoSourceText s
    1106 1160
     synifyTyLit (CharTyLit c) = HsCharTy NoSourceText c
    
    1107 1161
     
    
    1108 1162
     synifyKindSig :: Kind -> LHsKind GhcRn
    
    1109
    -synifyKindSig k = synifyType WithinType [] k
    
    1163
    +synifyKindSig k = synifyType WithinType emptyVarSet k
    
    1110 1164
     
    
    1111 1165
     stripKindSig :: LHsType GhcRn -> LHsType GhcRn
    
    1112 1166
     stripKindSig (L _ (HsKindSig _ t _)) = t
    
    ... ... @@ -1119,7 +1173,7 @@ synifyInstHead (vs, preds, cls, types) associated_families =
    1119 1173
         , ihdTypes = map unLoc annot_ts
    
    1120 1174
         , ihdInstType =
    
    1121 1175
             ClassInst
    
    1122
    -          { clsiCtx = map (unLoc . synifyType WithinType []) preds
    
    1176
    +          { clsiCtx = map (unLoc . synifyType WithinType emptyVarSet) preds
    
    1123 1177
               , clsiTyVars = synifyTyVars (tyConVisibleTyVars cls_tycon)
    
    1124 1178
               , clsiSigs = map synifyClsIdSig $ specialized_class_methods
    
    1125 1179
               , clsiAssocTys =
    
    ... ... @@ -1132,7 +1186,7 @@ synifyInstHead (vs, preds, cls, types) associated_families =
    1132 1186
       where
    
    1133 1187
         cls_tycon = classTyCon cls
    
    1134 1188
         ts = filterOutInvisibleTypes cls_tycon types
    
    1135
    -    ts' = map (synifyType WithinType vs) ts
    
    1189
    +    ts' = map (synifyType WithinType $ mkVarSet vs) ts
    
    1136 1190
         annot_ts = zipWith3 annotHsType args_poly ts ts'
    
    1137 1191
         args_poly = tyConArgsPolyKinded cls_tycon
    
    1138 1192
         synifyClsIdSig = synifyIdSig ShowRuntimeRep DeleteTopLevelQuantification vs
    
    ... ... @@ -1151,7 +1205,7 @@ synifyFamInst fi opaque = do
    1151 1205
       where
    
    1152 1206
         ityp SynFamilyInst | opaque = return $ TypeInst Nothing
    
    1153 1207
         ityp SynFamilyInst =
    
    1154
    -      return . TypeInst . Just . unLoc $ synifyType WithinType [] fam_rhs
    
    1208
    +      return . TypeInst . Just . unLoc $ synifyType WithinType emptyVarSet fam_rhs
    
    1155 1209
         ityp (DataFamilyInst c) =
    
    1156 1210
           DataInst <$> synifyTyCon HideRuntimeRep (Just $ famInstAxiom fi) c
    
    1157 1211
         fam_tc = famInstTyCon fi
    
    ... ... @@ -1173,7 +1227,7 @@ synifyFamInst fi opaque = do
    1173 1227
               fam_lhs
    
    1174 1228
     
    
    1175 1229
         ts = filterOutInvisibleTypes fam_tc eta_expanded_lhs
    
    1176
    -    synifyTypes = map (synifyType WithinType [])
    
    1230
    +    synifyTypes = map (synifyType WithinType emptyVarSet)
    
    1177 1231
         ts' = synifyTypes ts
    
    1178 1232
         annot_ts = zipWith3 annotHsType args_poly ts ts'
    
    1179 1233
         args_poly = tyConArgsPolyKinded fam_tc
    

  • utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
    ... ... @@ -856,8 +856,8 @@ tyCoFVsOfType' (TyConApp _ tys) a b c = tyCoFVsOfTypes' tys a b c
    856 856
     tyCoFVsOfType' (LitTy{}) a b c = emptyFV a b c
    
    857 857
     tyCoFVsOfType' (AppTy fun arg) a b c = (tyCoFVsOfType' arg `unionFV` tyCoFVsOfType' fun) a b c
    
    858 858
     tyCoFVsOfType' (FunTy _ w arg res) a b c =
    
    859
    -  ( tyCoFVsOfType' w
    
    860
    -      `unionFV` tyCoFVsOfType' res
    
    859
    +  ( tyCoFVsOfType' res
    
    860
    +      `unionFV` tyCoFVsOfType' w
    
    861 861
           `unionFV` tyCoFVsOfType' arg
    
    862 862
       )
    
    863 863
         a
    

  • utils/haddock/html-test/ref/Bug1050.html
    ... ... @@ -99,11 +99,7 @@
    99 99
     	    >mkT</a
    
    100 100
     	    > :: <span class="keyword"
    
    101 101
     	    >forall</span
    
    102
    -	    > {k} {f :: <span class="keyword"
    
    103
    -	    >forall</span
    
    104
    -	    > k1. k1 -&gt; <a href="#" title="Data.Kind"
    
    105
    -	    >Type</a
    
    106
    -	    >} {a :: k}. f a -&gt; <a href="#" title="Bug1050"
    
    102
    +	    > {k} {f} {a :: k}. f a -&gt; <a href="#" title="Bug1050"
    
    107 103
     	    >T</a
    
    108 104
     	    > f a <a href="#" class="selflink"
    
    109 105
     	    >#</a
    

  • utils/haddock/html-test/ref/LinearTypes.html
    ... ... @@ -64,11 +64,7 @@
    64 64
     	    ><li class="src short"
    
    65 65
     	    ><a href="#"
    
    66 66
     	      >poly</a
    
    67
    -	      > :: <span class="keyword"
    
    68
    -	      >forall</span
    
    69
    -	      > a (m :: <a href="#" title="GHC.Exts"
    
    70
    -	      >Multiplicity</a
    
    71
    -	      >) b. a %m -&gt; b</li
    
    67
    +	      > :: a %m -&gt; b</li
    
    72 68
     	    ><li class="src short"
    
    73 69
     	    ><span class="keyword"
    
    74 70
     	      >data</span
    
    ... ... @@ -163,11 +159,7 @@
    163 159
     	><p class="src"
    
    164 160
     	  ><a id="v:poly" class="def"
    
    165 161
     	    >poly</a
    
    166
    -	    > :: <span class="keyword"
    
    167
    -	    >forall</span
    
    168
    -	    > a (m :: <a href="#" title="GHC.Exts"
    
    169
    -	    >Multiplicity</a
    
    170
    -	    >) b. a %m -&gt; b <a href="#" class="selflink"
    
    162
    +	    > :: a %m -&gt; b <a href="#" class="selflink"
    
    171 163
     	    >#</a
    
    172 164
     	    ></p
    
    173 165
     	  ><div class="doc"
    

  • utils/haddock/html-test/ref/PatternSyns.html
    ... ... @@ -132,7 +132,9 @@
    132 132
     	      >pattern</span
    
    133 133
     	      > <a href="#"
    
    134 134
     	      >E</a
    
    135
    -	      > :: a <a href="#" title="PatternSyns"
    
    135
    +	      > :: <span class="keyword"
    
    136
    +	      >forall</span
    
    137
    +	      > {k} {a} {b :: k}. a <a href="#" title="PatternSyns"
    
    136 138
     	      >&gt;&lt;</a
    
    137 139
     	      > b</li
    
    138 140
     	    ><li class="src short"
    
    ... ... @@ -335,7 +337,9 @@
    335 337
     	    >pattern</span
    
    336 338
     	    > <a id="v:E" class="def"
    
    337 339
     	    >E</a
    
    338
    -	    > :: a <a href="#" title="PatternSyns"
    
    340
    +	    > :: <span class="keyword"
    
    341
    +	    >forall</span
    
    342
    +	    > {k} {a} {b :: k}. a <a href="#" title="PatternSyns"
    
    339 343
     	    >&gt;&lt;</a
    
    340 344
     	    > b <a href="#" class="selflink"
    
    341 345
     	    >#</a
    

  • utils/haddock/html-test/ref/PatternSyns2.html
    1
    +<html xmlns="http://www.w3.org/1999/xhtml"
    
    2
    +><head
    
    3
    +  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
    
    4
    +     /><meta name="viewport" content="width=device-width, initial-scale=1"
    
    5
    +     /><title
    
    6
    +    >PatternSyns2</title
    
    7
    +    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
    
    8
    +     /><link rel="stylesheet" type="text/css" href="#"
    
    9
    +     /><link rel="stylesheet" type="text/css" href="#"
    
    10
    +     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
    
    11
    +    ></script
    
    12
    +    ><script type="text/x-mathjax-config"
    
    13
    +    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
    
    14
    +    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
    
    15
    +    ></script
    
    16
    +    ></head
    
    17
    +  ><body
    
    18
    +  ><div id="package-header"
    
    19
    +    ><span class="caption empty"
    
    20
    +      >&nbsp;</span
    
    21
    +      ><ul class="links" id="page-menu"
    
    22
    +      ><li
    
    23
    +	><a href="#"
    
    24
    +	  >Contents</a
    
    25
    +	  ></li
    
    26
    +	><li
    
    27
    +	><a href="#"
    
    28
    +	  >Index</a
    
    29
    +	  ></li
    
    30
    +	></ul
    
    31
    +      ></div
    
    32
    +    ><div id="content"
    
    33
    +    ><div id="module-header"
    
    34
    +      ><table class="info"
    
    35
    +	><tr
    
    36
    +	  ><th
    
    37
    +	    >Safe Haskell</th
    
    38
    +	    ><td
    
    39
    +	    >None</td
    
    40
    +	    ></tr
    
    41
    +	  ><tr
    
    42
    +	  ><th
    
    43
    +	    >Language</th
    
    44
    +	    ><td
    
    45
    +	    >Haskell2010</td
    
    46
    +	    ></tr
    
    47
    +	  ></table
    
    48
    +	><p class="caption"
    
    49
    +	>PatternSyns2</p
    
    50
    +	></div
    
    51
    +      ><div id="interface"
    
    52
    +      ><h1
    
    53
    +	>Documentation</h1
    
    54
    +	><div class="top"
    
    55
    +	><p class="src"
    
    56
    +	  ><span class="keyword"
    
    57
    +	    >pattern</span
    
    58
    +	    > <a id="v:P1" class="def"
    
    59
    +	    >P1</a
    
    60
    +	    > :: () =&gt; <a href="#" title="Prelude"
    
    61
    +	    >Num</a
    
    62
    +	    > a =&gt; a -&gt; D <a href="#" title="Prelude"
    
    63
    +	    >Num</a
    
    64
    +	    > a <a href="#" class="selflink"
    
    65
    +	    >#</a
    
    66
    +	    ></p
    
    67
    +	  ></div
    
    68
    +	><div class="top"
    
    69
    +	><p class="src"
    
    70
    +	  ><span class="keyword"
    
    71
    +	    >pattern</span
    
    72
    +	    > <a id="v:P2" class="def"
    
    73
    +	    >P2</a
    
    74
    +	    > :: <a href="#" title="Prelude"
    
    75
    +	    >Num</a
    
    76
    +	    > a =&gt; a -&gt; a <a href="#" class="selflink"
    
    77
    +	    >#</a
    
    78
    +	    ></p
    
    79
    +	  ></div
    
    80
    +	><div class="top"
    
    81
    +	><p class="src"
    
    82
    +	  ><span class="keyword"
    
    83
    +	    >pattern</span
    
    84
    +	    > <a id="v:P3" class="def"
    
    85
    +	    >P3</a
    
    86
    +	    > :: () =&gt; <span class="keyword"
    
    87
    +	    >forall</span
    
    88
    +	    > (e :: <a href="#" title="GHC.Exts"
    
    89
    +	    >TYPE</a
    
    90
    +	    > '<a href="#" title="GHC.Exts"
    
    91
    +	    >DoubleRep</a
    
    92
    +	    >). <span class="breakable"
    
    93
    +	    >(<span class="unbreakable"
    
    94
    +	      >PCIR a</span
    
    95
    +	      >, <span class="unbreakable"
    
    96
    +	      >PCDR e</span
    
    97
    +	      >)</span
    
    98
    +	    > =&gt; a -&gt; e -&gt; Q a <a href="#" class="selflink"
    
    99
    +	    >#</a
    
    100
    +	    ></p
    
    101
    +	  ></div
    
    102
    +	><div class="top"
    
    103
    +	><p class="src"
    
    104
    +	  ><span class="keyword"
    
    105
    +	    >pattern</span
    
    106
    +	    > <a id="v:P4" class="def"
    
    107
    +	    >P4</a
    
    108
    +	    > :: RCIR a =&gt; <span class="keyword"
    
    109
    +	    >forall</span
    
    110
    +	    > (e :: <a href="#" title="GHC.Exts"
    
    111
    +	    >TYPE</a
    
    112
    +	    > '<a href="#" title="GHC.Exts"
    
    113
    +	    >DoubleRep</a
    
    114
    +	    >). <span class="breakable"
    
    115
    +	    >(<span class="unbreakable"
    
    116
    +	      >PCIR a</span
    
    117
    +	      >, <span class="unbreakable"
    
    118
    +	      >PCDR e</span
    
    119
    +	      >)</span
    
    120
    +	    > =&gt; a -&gt; e -&gt; Q a <a href="#" class="selflink"
    
    121
    +	    >#</a
    
    122
    +	    ></p
    
    123
    +	  ></div
    
    124
    +	><div class="top"
    
    125
    +	><p class="src"
    
    126
    +	  ><span class="keyword"
    
    127
    +	    >pattern</span
    
    128
    +	    > <a id="v:P5" class="def"
    
    129
    +	    >P5</a
    
    130
    +	    > :: RCIR a =&gt; <span class="keyword"
    
    131
    +	    >forall</span
    
    132
    +	    > (e :: <a href="#" title="GHC.Exts"
    
    133
    +	    >TYPE</a
    
    134
    +	    > '<a href="#" title="GHC.Exts"
    
    135
    +	    >DoubleRep</a
    
    136
    +	    >). a -&gt; e -&gt; Q a <a href="#" class="selflink"
    
    137
    +	    >#</a
    
    138
    +	    ></p
    
    139
    +	  ></div
    
    140
    +	><div class="top"
    
    141
    +	><p class="src"
    
    142
    +	  ><span class="keyword"
    
    143
    +	    >pattern</span
    
    144
    +	    > <a id="v:P" class="def"
    
    145
    +	    >P</a
    
    146
    +	    > :: () =&gt; <span class="keyword"
    
    147
    +	    >forall</span
    
    148
    +	    > k (a :: k) b. <a href="#" title="Prelude"
    
    149
    +	    >Show</a
    
    150
    +	    > b =&gt; <a href="#" title="Data.Proxy"
    
    151
    +	    >Proxy</a
    
    152
    +	    > a -&gt; b -&gt; A <a href="#" class="selflink"
    
    153
    +	    >#</a
    
    154
    +	    ></p
    
    155
    +	  ></div
    
    156
    +	></div
    
    157
    +      ></div
    
    158
    +    ></body
    
    159
    +  ></html
    
    160
    +>

  • utils/haddock/html-test/ref/TypeOperators.html
    ... ... @@ -185,17 +185,7 @@
    185 185
     	><p class="src"
    
    186 186
     	  ><a id="v:biO" class="def"
    
    187 187
     	    >biO</a
    
    188
    -	    > :: <span class="keyword"
    
    189
    -	    >forall</span
    
    190
    -	    > (g :: <a href="#" title="Data.Kind"
    
    191
    -	    >Type</a
    
    192
    -	    > -&gt; <a href="#" title="Data.Kind"
    
    193
    -	    >Type</a
    
    194
    -	    >) (f :: <a href="#" title="Data.Kind"
    
    195
    -	    >Type</a
    
    196
    -	    > -&gt; <a href="#" title="Data.Kind"
    
    197
    -	    >Type</a
    
    198
    -	    >) a. <a href="#" title="TypeOperators"
    
    188
    +	    > :: <a href="#" title="TypeOperators"
    
    199 189
     	    >O</a
    
    200 190
     	    > g f a <a href="#" class="selflink"
    
    201 191
     	    >#</a
    

  • utils/haddock/html-test/src/PatternSyns2.hs
    1
    +{-# LANGUAGE Haskell2010 #-}
    
    2
    +
    
    3
    +{-# LANGUAGE DataKinds #-}
    
    4
    +{-# LANGUAGE GADTs #-}
    
    5
    +{-# LANGUAGE PatternSynonyms #-}
    
    6
    +{-# LANGUAGE PolyKinds #-}
    
    7
    +{-# LANGUAGE ScopedTypeVariables #-}
    
    8
    +{-# LANGUAGE StandaloneKindSignatures #-}
    
    9
    +
    
    10
    +module PatternSyns2
    
    11
    +  ( pattern P1, pattern P2, pattern P3, pattern P4, pattern P5
    
    12
    +  , pattern P
    
    13
    +  )
    
    14
    +  where
    
    15
    +
    
    16
    +import Data.Kind
    
    17
    +import Data.Proxy
    
    18
    +import GHC.Exts
    
    19
    +
    
    20
    +type D :: ( Type -> Constraint ) -> Type -> Type
    
    21
    +data D c a where
    
    22
    +  MkD :: c a => a -> D c a
    
    23
    +
    
    24
    +pattern P1 :: () => Num a => a -> D Num a
    
    25
    +pattern P1 a = MkD a
    
    26
    +
    
    27
    +pattern P2 :: Num a => () => a -> a
    
    28
    +pattern P2 a = a
    
    29
    +
    
    30
    +type RCIR :: TYPE IntRep -> Constraint
    
    31
    +class RCIR a where
    
    32
    +
    
    33
    +type PCIR :: TYPE IntRep -> Constraint
    
    34
    +class PCIR a where
    
    35
    +
    
    36
    +type PCDR :: TYPE DoubleRep -> Constraint
    
    37
    +class PCDR a where
    
    38
    +
    
    39
    +type Q :: TYPE IntRep -> Type
    
    40
    +data Q a where
    
    41
    +  MkQ :: forall ( a :: TYPE IntRep ) ( e :: TYPE DoubleRep )
    
    42
    +      .  ( PCIR a, PCDR e )
    
    43
    +      => a -> e -> Q a
    
    44
    +
    
    45
    +pattern P3 :: forall (a :: TYPE IntRep). () => forall (e :: TYPE DoubleRep). (PCIR a, PCDR e) => a -> e -> Q a
    
    46
    +pattern P3 a e = MkQ a e
    
    47
    +
    
    48
    +pattern P4 :: forall (a :: TYPE IntRep). (RCIR a) => forall (e :: TYPE DoubleRep). (PCIR a, PCDR e) => a -> e -> Q a
    
    49
    +pattern P4 a e = MkQ a e
    
    50
    +
    
    51
    +pattern P5 :: forall (a :: TYPE IntRep). (RCIR a) => forall (e :: TYPE DoubleRep). () => a -> e -> Q a
    
    52
    +pattern P5 a e <- MkQ a e
    
    53
    +
    
    54
    +
    
    55
    +type A :: Type
    
    56
    +data A where
    
    57
    +  MkA :: forall k (a ::k) b. ( Show b ) => Proxy a -> b -> A
    
    58
    +
    
    59
    +pattern P :: forall . () => forall k (a :: k) b. ( Show b ) => Proxy a -> b -> A
    
    60
    +pattern P a b = MkA a b

  • utils/haddock/latex-test/ref/LinearTypes/LinearTypes.tex
    ... ... @@ -24,7 +24,7 @@ Does something linear.\par}
    24 24
     \end{haddockdesc}
    
    25 25
     \begin{haddockdesc}
    
    26 26
     \item[\begin{tabular}{@{}l}
    
    27
    -poly :: forall a (m :: Multiplicity) b. a {\char '45}m -> b
    
    27
    +poly :: a {\char '45}m -> b
    
    28 28
     \end{tabular}]
    
    29 29
     {\haddockbegindoc
    
    30 30
     Does something polymorphic.\par}