Print infix function definitions correctly in HsSyn
[ghc-hetmet.git] / compiler / rename / RnBinds.lhs
index 1c7bebb..d54f76e 100644 (file)
@@ -27,7 +27,7 @@ import TcRnMonad
 import RnTypes         ( rnHsSigType, rnLHsType, rnHsTypeFVs, 
                          rnLPat, rnPatsAndThen, patSigErr, checkPrecMatch )
 import RnEnv           ( bindLocatedLocalsRn, lookupLocatedBndrRn, 
 import RnTypes         ( rnHsSigType, rnLHsType, rnHsTypeFVs, 
                          rnLPat, rnPatsAndThen, patSigErr, checkPrecMatch )
 import RnEnv           ( bindLocatedLocalsRn, lookupLocatedBndrRn, 
-                         lookupLocatedInstDeclBndr, newIPNameRn,
+                         lookupInstDeclBndr, newIPNameRn,
                          lookupLocatedSigOccRn, bindPatSigTyVarsFV,
                          bindLocalFixities, bindSigTyVarsFV, 
                          warnUnusedLocalBinds, mapFvRn, extendTyVarEnvFVRn,
                          lookupLocatedSigOccRn, bindPatSigTyVarsFV,
                          bindLocalFixities, bindSigTyVarsFV, 
                          warnUnusedLocalBinds, mapFvRn, extendTyVarEnvFVRn,
@@ -380,7 +380,7 @@ rnBind sig_fn trim (L loc (FunBind { fun_id = name, fun_infix = inf, fun_matches
 
        ; (matches', fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
                                -- bindSigTyVars tests for Opt_ScopedTyVars
 
        ; (matches', fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
                                -- bindSigTyVars tests for Opt_ScopedTyVars
-                            rnMatchGroup (FunRhs plain_name) matches
+                            rnMatchGroup (FunRhs plain_name inf) matches
 
        ; checkPrecMatch inf plain_name matches'
 
 
        ; checkPrecMatch inf plain_name matches'
 
@@ -422,7 +422,7 @@ rnMethodBinds cls sig_fn gen_tyvars binds
 rnMethodBind cls sig_fn gen_tyvars (L loc (FunBind { fun_id = name, fun_infix = inf, 
                                                     fun_matches = MatchGroup matches _ }))
   = setSrcSpan loc $ 
 rnMethodBind cls sig_fn gen_tyvars (L loc (FunBind { fun_id = name, fun_infix = inf, 
                                                     fun_matches = MatchGroup matches _ }))
   = setSrcSpan loc $ 
-    lookupLocatedInstDeclBndr cls name                 `thenM` \ sel_name -> 
+    lookupInstDeclBndr cls name                        `thenM` \ sel_name -> 
     let plain_name = unLoc sel_name in
        -- We use the selector name as the binder
 
     let plain_name = unLoc sel_name in
        -- We use the selector name as the binder
 
@@ -444,12 +444,12 @@ rnMethodBind cls sig_fn gen_tyvars (L loc (FunBind { fun_id = name, fun_infix =
        -- type variables.  See comments in RnSource.rnSourceDecl(ClassDecl)
     rn_match sel_name match@(L _ (Match (L _ (TypePat ty) : _) _ _))
        = extendTyVarEnvFVRn gen_tvs    $
        -- type variables.  See comments in RnSource.rnSourceDecl(ClassDecl)
     rn_match sel_name match@(L _ (Match (L _ (TypePat ty) : _) _ _))
        = extendTyVarEnvFVRn gen_tvs    $
-         rnMatch (FunRhs sel_name) match
+         rnMatch (FunRhs sel_name inf) match
        where
          tvs     = map (rdrNameOcc.unLoc) (extractHsTyRdrTyVars ty)
          gen_tvs = [tv | tv <- gen_tyvars, nameOccName tv `elem` tvs] 
 
        where
          tvs     = map (rdrNameOcc.unLoc) (extractHsTyRdrTyVars ty)
          gen_tvs = [tv | tv <- gen_tyvars, nameOccName tv `elem` tvs] 
 
-    rn_match sel_name match = rnMatch (FunRhs sel_name) match
+    rn_match sel_name match = rnMatch (FunRhs sel_name inf) match
 
 
 -- Can't handle method pattern-bindings which bind multiple methods.
 
 
 -- Can't handle method pattern-bindings which bind multiple methods.
@@ -555,10 +555,10 @@ rnMatch' ctxt match@(Match pats maybe_rhs_sig grhss)
   = 
        -- Deal with the rhs type signature
     bindPatSigTyVarsFV rhs_sig_tys     $ 
   = 
        -- Deal with the rhs type signature
     bindPatSigTyVarsFV rhs_sig_tys     $ 
-    doptM Opt_GlasgowExts              `thenM` \ opt_GlasgowExts ->
+    doptM Opt_PatternSignatures `thenM` \ opt_PatternSignatures ->
     (case maybe_rhs_sig of
        Nothing -> returnM (Nothing, emptyFVs)
     (case maybe_rhs_sig of
        Nothing -> returnM (Nothing, emptyFVs)
-       Just ty | opt_GlasgowExts -> rnHsTypeFVs doc_sig ty     `thenM` \ (ty', ty_fvs) ->
+       Just ty | opt_PatternSignatures -> rnHsTypeFVs doc_sig ty       `thenM` \ (ty', ty_fvs) ->
                                     returnM (Just ty', ty_fvs)
                | otherwise       -> addLocErr ty patSigErr     `thenM_`
                                     returnM (Nothing, emptyFVs)
                                     returnM (Just ty', ty_fvs)
                | otherwise       -> addLocErr ty patSigErr     `thenM_`
                                     returnM (Nothing, emptyFVs)
@@ -596,11 +596,11 @@ rnGRHS :: HsMatchContext Name -> LGRHS RdrName -> RnM (LGRHS Name, FreeVars)
 rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt)
 
 rnGRHS' ctxt (GRHS guards rhs)
 rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt)
 
 rnGRHS' ctxt (GRHS guards rhs)
-  = do { opt_GlasgowExts <- doptM Opt_GlasgowExts
+  = do { pattern_guards_allowed <- doptM Opt_PatternGuards
        ; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $
                                    rnLExpr rhs
 
        ; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $
                                    rnLExpr rhs
 
-       ; checkM (opt_GlasgowExts || is_standard_guard guards')
+       ; checkM (pattern_guards_allowed || is_standard_guard guards')
                 (addWarn (nonStdGuardErr guards'))
 
        ; return (GRHS guards' rhs', fvs) }
                 (addWarn (nonStdGuardErr guards'))
 
        ; return (GRHS guards' rhs', fvs) }
@@ -653,6 +653,6 @@ bindsInHsBootFile mbinds
        2 (ppr mbinds)
 
 nonStdGuardErr guards
        2 (ppr mbinds)
 
 nonStdGuardErr guards
-  = hang (ptext SLIT("accepting non-standard pattern guards (-fglasgow-exts to suppress this message)"))
+  = hang (ptext SLIT("accepting non-standard pattern guards (use -XPatternGuards to suppress this message)"))
        4 (interpp'SP guards)
 \end{code}
        4 (interpp'SP guards)
 \end{code}