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

Commits:

3 changed files:

Changes:

  • compiler/GHC/Core/Class.hs
    ... ... @@ -84,9 +84,9 @@ data Class
    84 84
     --  Here fun-deps are [([a,b],[c]), ([a,c],[b])]
    
    85 85
     type FunDep a = ([a],[a])
    
    86 86
     
    
    87
    -type ClassOpItem = (Id, DefMethInfo)
    
    88
    -        -- Selector function; contains unfolding
    
    89
    -        -- Default-method info
    
    87
    +type ClassOpItem = ( Id           -- Dictionary selector function
    
    88
    +                                  -- See Note [Dictionary selectors]
    
    89
    +                   , DefMethInfo) -- Default-method info
    
    90 90
     
    
    91 91
     type DefMethInfo = Maybe (Name, DefMethSpec Type)
    
    92 92
        -- Nothing                    No default method
    
    ... ... @@ -164,7 +164,19 @@ classMinimalDef :: Class -> ClassMinimalDef
    164 164
     classMinimalDef Class{ classBody = ConcreteClass{ cls_min_def = d } } = d
    
    165 165
     classMinimalDef _ = mkTrue -- TODO: make sure this is the right direction
    
    166 166
     
    
    167
    -{-
    
    167
    +{- Note [Dictionary selectors]
    
    168
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    169
    +Each `ClassOpItem` stores a dictionary selector `Id`:
    
    170
    +
    
    171
    +* The type of the selector is always closed, and has form
    
    172
    +      forall a1..an. C a1 .. an => blah
    
    173
    +  where `a1..an` are the class variables, and
    
    174
    +        `blah` is the method type.
    
    175
    +  See GHC.Types.Id.Make.mkDictSelId, which constructs them.
    
    176
    +
    
    177
    +* The selector has no unfolding, but one RULE.
    
    178
    +  See Note [ClassOp/DFun selection] in GHC.Tc.TyCl.Instance
    
    179
    +
    
    168 180
     Note [Associated type defaults]
    
    169 181
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    170 182
     The following is an example of associated type defaults:
    

  • compiler/GHC/Rename/HsType.hs
    ... ... @@ -1188,10 +1188,20 @@ bindHsOuterTyVarBndrs :: OutputableBndrFlag flag 'Renamed
    1188 1188
                           -> RnM (a, FreeNames)
    
    1189 1189
     bindHsOuterTyVarBndrs doc mb_cls implicit_vars outer_bndrs thing_inside =
    
    1190 1190
       case outer_bndrs of
    
    1191
    +
    
    1191 1192
         HsOuterImplicit{} ->
    
    1193
    +      -- Add an implicit `forall a1..an` at the top, where `a1..an`
    
    1194
    +      -- are not-otherwise-in-scope type variables.
    
    1195
    +      -- Used when there is no forall, or a /visible/ (forall a -> blah)
    
    1196
    +      -- See Note [forall-or-nothing rule] in Language.Haskell.Syntax.Type
    
    1192 1197
           rnImplicitTvOccs mb_cls implicit_vars $ \implicit_vars' ->
    
    1193 1198
             thing_inside $ HsOuterImplicit { hso_ximplicit = implicit_vars' }
    
    1199
    +
    
    1194 1200
         HsOuterExplicit{hso_bndrs = exp_bndrs} ->
    
    1201
    +      -- The type already has an explicit, user-written, invisible forall,
    
    1202
    +      --     so do not add an implicit forall
    
    1203
    +      -- See Note [forall-or-nothing rule] in Language.Haskell.Syntax.Type
    
    1204
    +      --
    
    1195 1205
           -- Note: If we pass mb_cls instead of Nothing below, bindLHsTyVarBndrs
    
    1196 1206
           -- will use class variables for any names the user meant to bring in
    
    1197 1207
           -- scope here. This is an explicit forall, so we want fresh names, not
    

  • compiler/GHC/Types/Id/Make.hs
    ... ... @@ -480,7 +480,7 @@ Therefore there is no loss of generality if we make all selectors unrestricted.
    480 480
     mkDictSelId :: Name          -- Name of one of the *value* selectors
    
    481 481
                                  -- (dictionary superclass or method)
    
    482 482
                 -> Class -> Id
    
    483
    --- Important: see Note [ClassOp/DFun selection] in GHC.Tc.TyCl.Instance
    
    483
    +-- See Note [Dictionary selectors]
    
    484 484
     mkDictSelId name clas
    
    485 485
       = mkGlobalId (ClassOpId clas terminating) name sel_ty info
    
    486 486
       where